简体   繁体   English

为什么在 angular6 的 ng-multiselect-dropdown 中未定义 idField?

[英]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 后,将*ngIfng-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.

相关问题 angular ng-multiselect-dropdown 获取 id - angular ng-multiselect-dropdown get id 如何使用 ng-multiselect-dropdown 在 angular 中将选择选项设为默认选择? - How to make a select option as default selected in angular using ng-multiselect-dropdown? 有没有办法在 ng-multiselect-dropdown 关闭时添加功能? - Is there a way to add a function on close of ng-multiselect-dropdown? 如何为 ng-multiselect-dropdown 的 onselect 事件传递多个项目 - How to pass multiple items for onselect event for ng-multiselect-dropdown 单击时自动聚焦 ng-multiselect-dropdown 的过滤字段 - Focus Filterfield of ng-multiselect-dropdown automatically when clicked ng-multiselect-dropdown - 'IDropdownSettings' 仅指一种类型,但在此处用作值 - ng-multiselect-dropdown - 'IDropdownSettings' only refers to a type, but is being used as a value here 有什么方法可以在 ng-multiselect-dropdown 插件的搜索框中检测或添加按键/点击事件 - Is there any way to detect or add an on-keypress/click event in search box of ng-multiselect-dropdown plugin 我正在使用“ng-multiselect-dropdown”但是当我 select 列表选择的值显示在下拉列表的输入侧 - i am using "ng-multiselect-dropdown" but when i select list selected values is shown in input side of dropdown ng-multiselect-dropdown-angular7 (onDeSelect) 不起作用 - ng-multiselect-dropdown-angular7 (onDeSelect) not working 如何在ng-dropdown-multiselect上使用角度转换 - How to use angular translate on ng-dropdown-multiselect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM