离子3侧栏添加徽章通知不起作用

时间:2019-04-12 09:53:56

标签: ionic-framework ionic2 ionic3

我将* *Ionic 3 - badge **用于我的应用程序侧边栏。添加徽章但未显示时遇到了一些冲突 任何人都知道如何在侧边栏中显示徽章 谢谢

我的代码部分

app.html

   <ion-list class="user-list" >
      <button ion-item menuClose class="text-1x" *ngFor="let menuItem of appMenuItems" (click)="openPage(menuItem)" >
        <ion-icon item-left [name]="menuItem.icon" style="color: black; " ></ion-icon>
        <span ion-text style="color: black; border-bottom: none;">{{menuItem.title}}</span>
        <ion-badge">{{p.badgeCount}}</ion-badge>
      </button>
    </ion-list>

app.component.ts

export interface MenuItem {
  title: string;
  component: any;
  icon: string;
  buttonName:string;


}


@Component({
  templateUrl: 'app.html'
})

export class MyApp {
  @ViewChild(Nav) nav: Nav;
  rootPage: any = SigninPage;
  selectedTheme: String;

  appMenuItems: Array<MenuItem>;


  constructor(public platform: Platform, private settings: SettingsProvider, private master: master) {

    this.settings.getActiveTheme().subscribe(val => this.selectedTheme = val);

    this.appMenuItems = [
      {title: 'Home', component: HomePage, icon: 'ios-home-outline'},

      {title: 'Notification', component: CheckoutPage, icon: 'ios-basket-outline',buttonName: 'badgeNumber ',},

    ];


  }

1 个答案:

答案 0 :(得分:0)

我爱上我的问题

我更改了此<ion-badge>{{menuItem.badgeCount}}</ion-badge>

app.component.ts

export interface MenuItem {
  title: string;
  component: any;
  icon: string;
  buttonName:string;


}


@Component({
  templateUrl: 'app.html'
})

export class MyApp {
  @ViewChild(Nav) nav: Nav;
  rootPage: any = SigninPage;
  selectedTheme: String;

  appMenuItems: Array<MenuItem>;


  constructor(public platform: Platform, private settings: SettingsProvider, private master: master) {

    this.settings.getActiveTheme().subscribe(val => this.selectedTheme = val);

    this.appMenuItems = [
      {title: 'Home', component: HomePage, icon: 'ios-home-outline'},

      {title: 'Notification', component: CheckoutPage, icon: 'ios-basket-outline',badgeCount: '5 ',},

    ];


  }

app.html

 <ion-list class="user-list" >
      <button ion-item menuClose class="text-1x" *ngFor="let menuItem of appMenuItems" (click)="openPage(menuItem)" >
        <ion-icon item-left [name]="menuItem.icon" style="color: black; " ></ion-icon>
        <span ion-text style="color: black; border-bottom: none;">{{menuItem.title}}</span>
        <ion-badge>{{menuItem.badgeCount}}</ion-badge>
      </button>
    </ion-list>