不触发ngModelChange

时间:2017-09-28 10:41:56

标签: angular angular2-template angular-ngmodel

我试图实现一个过滤选项来列出和排序一些东西。定义[ngModel]="filter2",但(ngModelChange)永远不会被解雇。我有一种感觉,我理解这个概念有点不对.. 我做错了什么想法?

模板:

<ion-segment  [(ngModel)]="selectedFilter" (ionChange)="selectFilter($event)">
    <ion-segment-button value="filter">
      FILTER
    </ion-segment-button>
    <ion-segment-button value="placementDate">
      Placement Date
    </ion-segment-button>
  </ion-segment>
</div>
<div [ngSwitch]="selectedFilter">
  <ion-list  *ngSwitchCase="'filter'">
    <ion-item *ngFor="let item of filterItems ">
        <ion-label>{{item.label | translate}} </ion-label>
          <ion-toggle [(ngModel)]="item.checked" [checked]="item.checked" (ionChange)="selectFilter(item)"></ion-toggle>
    </ion-item>
  </ion-list>
</div>
<div [ngSwitch]="selectedFilter">
  <ion-list [ngModel]="filter2" radio-group *ngSwitchCase="'placementDate'">
    <ion-item>
      <ion-label>Placement Date</ion-label>
      <ion-radio [value]="filter2.pDate" checked (ngModelChange)="valueChange($event)"></ion-radio>
    </ion-item>
    <ion-item>
      <ion-label>Settlement Date</ion-label>
      <ion-radio [value]="filter2.sDate" (ngModelChange)="valueChange($event)"></ion-radio>
    </ion-item>
    <ion-item>
      <ion-label>Status</ion-label>
      <ion-radio [value]="filter2.status" (ngModelChange)="valueChange($event)"></ion-radio>
    </ion-item>
    <ion-item>
      <ion-label>Type</ion-label>
      <ion-radio [value]="filter2.type" (ngModelChange)="valueChange($event)"></ion-radio>
    </ion-item>
  </ion-list>

班级:

public filter2 = {pDate:false,type:false,status:false,sDate:false}; //default values

0 个答案:

没有答案