[英]Why idField is undefined in ng-multiselect-dropdown in angular6?
我有ng-multiselect-dropdown
angular 應用程序。 為了提供dropdown
列表,我從ngOnInit
內部的api
獲取services
,就像這樣
selectedOfferedServices: IDropdownSettings = {};
ngOnInit(){
this.getServices();
this.selectedOfferedServices = {
singleSelection: false,
idField: 'id',
textField: 'deliveryTypeName',
selectAllText: 'Select All',
unSelectAllText: 'UnSelect All',
itemsShowLimit: 2,
allowSearchFilter: false
};
}
在我的template
我有一個條件*ngIf
並且在*ngIf
表達式中獲得 true 后,將*ngIf
此ng-multiselect-dropdown
*ngIf
ng-multiselect-dropdown
。 當用戶從我的模板中的普通select
dropdwon 中選擇任何選項時,此表達式變為真,然后顯示此ng-multi-select-dropdown
。
<div class="row" *ngIf="transporterOtherDetails === 'yes'">
<div class="col-3">
<div class="form-group">
<label>Offered Services</label>
<ng-multiselect-dropdown [placeholder]="'Select services'" [data]="deliverytypes"
[(ngModel)]="selectedServices" [ngModelOptions]="{standalone: true}"
[settings]="dropdownSettings">
</ng-multiselect-dropdown>
</div>
</div>
</div>
但這里的問題是,當我從模板中的正常dropdown
中選擇選項時,這個ng-multi-select-dropdown
顯示但在控制台錯誤是這樣的
ERROR TypeError: Cannot read property 'idField' of undefined at ng-multiselect-dropdown.js:189
任何人都可以讓我知道這有什么問題嗎?
我得到了解決方案。 我解決了這個問題,只是在data
參數之前移動我的settings
參數。 這對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.