[英]Why idField is undefined in ng-multiselect-dropdown in angular6?
I have angular app in which i have ng-multiselect-dropdown
.我有
ng-multiselect-dropdown
angular 应用程序。 To provide list to dropdown
i am getting services
from an api
inside of ngOnInit
like this为了提供
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
};
}
And inside my template
i have a condition of *ngIf
and upon getting the true inside of *ngIf
expression this ng-multiselect-dropdown
is shown.在我的
template
我有一个条件*ngIf
并且在*ngIf
表达式中获得 true 后,将*ngIf
此ng-multiselect-dropdown
*ngIf
ng-multiselect-dropdown
。 When user selects any option from normal select
dropdwon in my template so this expression becomes true and then this ng-multi-select-dropdown
is shown.当用户从我的模板中的普通
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>
But the problem here is that when i select option from normal dropdown
in my template so this ng-multi-select-dropdown
shows but in console error is coming like this但这里的问题是,当我从模板中的正常
dropdown
中选择选项时,这个ng-multi-select-dropdown
显示但在控制台错误是这样的
ERROR TypeError: Cannot read property 'idField' of undefined at ng-multiselect-dropdown.js:189
can any one let me know that what's the issue with this?任何人都可以让我知道这有什么问题吗?
I got the solution for this.我得到了解决方案。 I fixed this issue to just move my
settings
param before data
param.我解决了这个问题,只是在
data
参数之前移动我的settings
参数。 And this works for me.这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.