Question about how to findViewById within a component, within a component


Hi. I’m only a week into this, so please don’t give me a hard time.

I’ve been tinkering around with a slide drawer where the drawer content is specified in a separate component. The drawer contains a ListView which I’d like to grab a reference to in the component, this is so that I can set the tableFooterView to remove the empty rows from showing (and also to learn) I’ve tried a few things:


@ViewChild(ListView) public listView: ListView;



this one crashes because (Can’t resolve all parameters for SlidedrawerComponent)

constructor(protected page: Page) { }

the component that is embedded into the RadSlideDrawer’s tkDrawerContent

<GridView >
    <ListView id="listView"  [items]="items"  >
        <ng-template let-item="item">

The problem is that I can’t seem to inject a page variable via the constructor because it’s not instantiated like a normal page.

Should I be specificing a provider somewhere?
Or should I be grabbing the page somewhere in the component module’s onLoad function?

Any help would be much appreciated.
Thanks, David.


You must include NativeScriptCommonModule in your module which adds the provider for Page.

@ViewChild may be recommended over assigning actual ids when using Angular.


Thanks, I’ll give this a try soon. Is there any documentation about this? Specifically why you have to include NativeScriptCommonModule in your module as I can’t find anything about this.