Trying to access the headerExpand property from app.component is causing an error message in the console:
metadata_resolver.js:559 Uncaught Error: Invalid providers for "Page1" - only instances of Provider and Type are allowed, got: [?undefined?]
page1.ts
<pre>
import { Component } from '@angular/core';
import { MyApp } from '../../app/app.component';
@Component({
selector: 'page-page1',
templateUrl: 'page1.html',
})
export class Page1 {
constructor(public miApp: MyApp) {
console.log(miApp.headerExpand);
}
</pre>
app.component.ts
<pre>
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = Page1;
public headerExpand: boolean;
public pages: Array<{title: string, component: any}>;
constructor(public platform: Platform) {
this.initializeApp();
this.headerExpand = true;
}
initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
});
}
openPage(page) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component);
}
expandHeader(){
this.headerExpand = false;
}
}