多选错误this.value未定义

时间:2017-01-26 18:01:53

标签: angular kendo-ui-angular2

我正在尝试在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
}

1 个答案:

答案 0 :(得分:0)

这可能是一个问题,即视图在数据到达之前呈现,因此请尝试放置ngIf,如下所示:

<kendo-multiselect *ngIf="watchbills" name="watchbill" [data]="watchbills" 
     [(ngModel)]="selectedWatchbills" [textField]="'name'" [valueField]="'id'"></kendo-multiselect>

等待在呈现包含在该标记内的任何内容之前,数组watchbills中将存在值。