Angular Material ngModel on md-select not binding

时间:2017-09-06 09:49:08

标签: angular angular-material2

我的班级中有一个角度素材选择绑定到appraisalPeriod变量:

<md-select placeholder="Select Appraisal Period" class="custom-select" id="appraisalPeriod" name="appraisalPeriod" [(ngModel)]="appraisalPeriod" (ngModelChange)="onApprisalChange($event)" floatPlaceholder="never">
     <md-option *ngFor="let period of appraisalPeriodList | keys" [value]="period.key">{{period.value}}</md-option>
</md-select>

期间的一个例子:{“201707”:“2017Q2”}

我的.ts文件中有一个发射器:

this.emitterGoalsheet.subscribe(goalSheet => {
   this.appraisalPeriod = goalSheet.appraisal_id;
   alert(this.appraisalPeriod);
 });

但是,当提取appraisalPeriod属性时(如显示的警告框所示),选择框值不会自行更新并保持为空。

其他信息: keys.pipe.ts档案:

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({  name: 'keys'})
export class KeysPipe implements PipeTransform {

    transform(value: any, args: string[]): any {
    const keys = [];
    for ( const key in value ) {
      if (value.hasOwnProperty(key)) {
        keys.push({key: key, value: value[key]});
      }
    }
    return keys;
  }

}

0 个答案:

没有答案