我正在研究 Ionic2 + Angular2,我想使用段,所以我使用ngSwitchWhen
了,但它不起作用。发生错误。
我该如何使用它?为什么它不起作用?
这是错误消息。
<ion-toolbar>
<ion-segment [(ngModel)]="menuSelect" color="important">
<ion-segment-button value="light">
Light
</ion-segment-button>
<ion-segment-button value="sensor">
Sensor
</ion-segment-button>
</ion-segment>
</ion-toolbar>
<ion-content [ngSwitch]="menuSelect">
<!--func+ - light-->
<ion-item *ngSwitchWhen="'light'">
<ion-list>
<ion-list-header>
<ion-label>On/Off</ion-label>
<ion-toggle (click)="toggleLight()"></ion-toggle>
</ion-list-header>
</ion-list>
<!--light-off-->
<div [hidden]="lightOn">
<div class="light-off">Please turn on the light.</div>
</div>
<!--light-on-->
<div [hidden]="!lightOn">
<ion-list>
<ion-list-header class="title">
Color
</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header class="title">
Brightness
<ion-badge>{{brightness}}</ion-badge>
</ion-list-header>
<ion-item>
<ion-range min="0" max="5" step="1" snaps="true" [(ngModel)]="brightness">
<ion-icon range-left small name="sunny"></ion-icon>
<ion-icon range-right name="sunny"></ion-icon>
</ion-range>
</ion-item>
</ion-list>
</div>
</ion-item>
<!--func+ - sensor-->
<ion-item *ngSwitchWhen="'sensor'">
<ion-list>
<ion-list-header>
<ion-label>On/Off</ion-label>
</ion-list-header>
</ion-list>
</ion-item>
</ion-content>