我的代码
<select [formControl]="requestForm.controls['SellCommodityId']"> <option [value]="" disabled selected>COMMODITY/GRADE</option> <option [value]="item.Id" *ngFor="let item of fieldOptions?.Product;">{{item.Value}}</option> </select>
更新12-20-2016
我将select放入其中的一个Component,如下所示:
import { Component,ChangeDetectionStrategy,Input } from '@angular/core'; /** * <ihda-select [list]="list" [control]="control" [titleOption]="title"></ihda-select> */ @Component({ selector:'ihda-select',changeDetection:ChangeDetectionStrategy.OnPush,template:` <select [formControl]="control" class="form-control"> <option [value]="" disabled selected>{{titleOption}}</option> <option [value]="item.Id" *ngFor="let item of list">{{item.Value}}</option> </select> `,styleUrls: ['../app.component.css'] }) export class IHDASelect{ @Input() list: any[]; @Input() control: any; @Input() titleOption: string; }
性能问题持续存在.
看起来它不是changeDetection,因为我尝试从< select>中删除[formControl]属性.然后不再存在性能问题.似乎在此处使用[formControl]属性来跟踪表单组会导致性能问题.有关于此的信息吗?或者我如何解决它?
更新2016年12月21日