我正在尝试在Angular 2的Kendo UI中使用新的多选组件,但是当小部件启动时,Firebug中会出现“this.value is undefined”错误。
<kendo-multiselect name="watchbill" [data]="watchbills" [(ngModel)]="selectedWatchbills" [textField]="'name'" [valueField]="'id'"></kendo-multiselect>
selectedWatchbills: Watchbill[];
watchbills: Watchbill[];
ngOnInit() {
this.shipDataService.getWatchbills(this.startTime, this.endTime).subscribe(
data => this.watchbills = data
);
}
export interface Watchbill {
id: string,
name: string
}
答案 0 :(得分:0)
这可能是一个问题,即视图在数据到达之前呈现,因此请尝试放置ngIf
,如下所示:
<kendo-multiselect *ngIf="watchbills" name="watchbill" [data]="watchbills"
[(ngModel)]="selectedWatchbills" [textField]="'name'" [valueField]="'id'"></kendo-multiselect>
等待在呈现包含在该标记内的任何内容之前,数组watchbills
中将存在值。