I am trying to use app.component.ts
function in a page, but getting error .
EXCEPTION: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'e.pages.updatePages')
Function in app.component.ts :
updatePages(pages){
console.log(pages);
}
Code in page.ts
this.sidebarpage = [{ title: 'My Account', component: MyAccountPage }];
this.pages.updatePages(this.sidebarpage);
Already imported component in page.ts and added @ViewChild(MyApp) pages: MyApp;
app.component.ts is not a child page. ViewChild decorator is used when you are accessing a child component set in your corresponding html page and there is generally no need to use root tags in other pages.
You should create a provider class for this. Set the function in the provider and set the class in providers array app.module.ts to use in your components. More here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.