Update:
Actually, I have implemented "toggle menu" as on this doc.Please see that.The toggle menu is working fine.But I need to get the latest token when a user clicks the toggle menu.It works only with the constructor.After that, I cannot do that.That is may be due to the Root component.How can I achieve that?
Ionic2 Toggle Menu
Which life cycle event can I access after creating the app.component.ts
component? First time it fires constructor()
code.But after that none of the lifecycle events are working.
My scenario: I have implemented side menu as shown below on Ionic2 app.
app.html
<ion-menu [content]="content">
<ion-content padding>
<img src="./assets/img/login.png" alt="Login" (click)="login()" *ngIf="token!=null && token.length==0" menuClose>
//removed for clarity
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
Now I need to get the token value each and every time user clicks on above menu.But it works only once.After that, it's not working.Can you tell me a workaround for this?
app.component.ts
export class MyApp extends HandleStorageService {
@ViewChild(Nav) nav: Nav;
rootPage = EventSchedulePage;
menuList: Observable<any>;
token: string = '';
constructor(platform: Platform, public menuData: MenuData, public loadingCtrl: LoadingController, public storage: Storage) {
super(storage);
platform.ready().then(() => {
StatusBar.styleDefault();
Splashscreen.hide();
});
this.getMenuList();//menu list
}
ionViewDidEnter() {// not working this
this.getToken().then((val) => {//get token
this.token = val;
});
}