我使用最新版本的離子2.Ionic2動態設置欄項目
離子版本:2.1.8
我想在側邊欄動態添加的項目。
app.component.ts;
export class MyApp {
pages: Array<{title: string, component: any, icon: any }>;
this.pages = [
{ title: 'Dashboard', component: DashboardComponent, icon: 'ios-home-outline' },
{ title: 'Complaints', component: ComplaintPage, icon: 'ios-sad-outline' },
{ title: 'Suggestions', component: SuggestionPage, icon: 'md-bulb' },
{ title: 'Appreciations', component: AppreciationPage, icon: 'ios-thumbs-up-outline' },
{ title: 'Poll', component: PollPage, icon: 'ios-stats-outline' },
{ title: 'Survey', component: SurveyPage, icon: 'ios-analytics-outline' },
{ title: 'ReportIssue', component: ReportIssuePage, icon: 'ios-bug-outline' },
];
}
app.html
<ion-content>
<ion-list>
<button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
<ion-icon item-left [name]="p.icon"></ion-icon>
{{p.title}}
</button>
</ion-list>
</ion-content>
我想說明的投訴項目,如果投訴狀態爲 'NEW'。
那麼,是否可以顯示某些特定條件的投訴項目?我嘗試ngIf但它不起作用。
什麼是實現這種功能的最佳方式?
當你試圖'* ngIf'又如何呢? –
這個特定的條件可能會改變,然後在代碼的其他部分?那麼當這種情況發生時應該更新側面菜單? – sebaferreras