【发布时间】:2019-05-19 06:56:29
【问题描述】:
我在app.component.html 中设置了导航,我想在该模板中使用*ngIf。但是,由于 ionViewWillEnter 等生命周期钩子在 app.component.ts 中不起作用,我如何在每次弹出侧导航时触发调用?
我只是想得到一个红点来显示我的数组中是否有notifications
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({
...
我要添加到侧导航逻辑的内容
const newData = await this.api.listModel('Notification', {
page: this.page
});
this.notifications = this.notifications.concat(newData);
this.notifications = _.filter(this.notifications, { isActioned: false }
【问题讨论】:
标签: angular ionic-framework ionic4