I have my navigation set up in my app.component.html
, and I would like to use an *ngIf
inside that template. However, since lifecycle hooks like ionViewWillEnter
, etc don’t work in app.component.ts
, how can I trigger a call to fire every time the side nav is popped open?
I am just trying to get a red dot to show if there are notifications
in my array
app.component.html
...
<ion-list>
<ion-menu-toggle auto-hide="false" *ngFor="let p of appPages">
<ion-item [routerDirection]="'root'" [routerLink]="[p.url]">
<ion-icon slot="start" [name]="p.icon"></ion-icon>
=====>HERE===><div class="red-dot" *ngIf="p.title == 'Home' && notifications.length > 0"></div>
<ion-label>
{{p.title}}
</ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
</ion-content>
</ion-menu>
<ion-router-outlet main></ion-router-outlet>
...
app.component.ts
...
initializeApp() {
const parseQueryString = (queryString) => {
const query = <any>{};
for (let param of queryString.split('&')) {
const pair = param.split('=');
query[pair[0]] = pair[1];
}
return query;
};
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
this.deepLinks.route({
...
What I want to add to the side nav logic
const newData = await this.api.listModel('Notification', {
page: this.page
});
this.notifications = this.notifications.concat(newData);
this.notifications = _.filter(this.notifications, { isActioned: false }