简体   繁体   English

我正在使用“ng-multiselect-dropdown”但是当我 select 列表选择的值显示在下拉列表的输入侧

[英]i am using "ng-multiselect-dropdown" but when i select list selected values is shown in input side of dropdown

This is html of multiselect-dropdownList这是多选下拉列表的 html
i am using "ng-multiselect-dropdown" but when i select list selected values is shown in input side of dropdown我正在使用“ng-multiselect-dropdown”但是当我 select 列表选择的值显示在下拉列表的输入侧

  <div class="multiselect-dropdownList">
    <[![ng-multiselect-dropdown][1]][1]
     required 
        name="city"
        [placeholder]="'VendorList'"
        [data]="designerList"
        [settings]="dropdowDesiner"
        (onSelect)="onChangeDesignerList($event)"
        (onSelectAll)="onChangeDesignerList($event)"
        (onDeSelect)="onChangeDesignerList($event)"
        (onDropDownClose)="onDropDownClose()"
        
        >
      </ng-multiselect-dropdown>
    </div>
</div>

在此处输入图像描述

  • If You are using ng-multiselect-dropdown then all records must be show in input field如果您使用的是 ng-multiselect-dropdown,则所有记录都必须显示在输入字段中

  • You can use css to hide this.您可以使用 css 来隐藏它。 eg.ng-select /deep/ select-dropdown.selected { display: none } eg.ng-select /deep/ select-dropdown.selected { display: none }

you can bind a variable, which contains elements you want to preselect, something like this:您可以绑定一个变量,其中包含您要预选的元素,如下所示:

equals(objOne, objTwo) {
    if (typeof objOne !== 'undefined' && typeof objTwo !== 'undefined') {
      return objOne.id === objTwo.id;
    }
}
selectAll(checkAll, select: NgModel, values) {
    //this.toCheck = !this.toCheck;
    if(checkAll){
      select.update.emit(values); 
    }
    else{
      select.update.emit([]);
    }
  }

[(ngModel)]="selectedYears" [compareWith]="equals"  [multiple]= true 

And then you can just filter your initial array of items and get only those, which you want to select by default (it should be stored in selection class property in provided case).然后您可以过滤您的初始项目数组并仅获取那些默认情况下您想要 select 的项目(在提供的情况下,它应该存储在选择 class 属性中)。

I have used the disabled:true property to disable it and to hide the dropdown I have used the class .multiselect-dropdown {.dropdown-list { display: none;important; } }我使用 disabled:true 属性来禁用它并隐藏下拉列表 我使用了 class .multiselect-dropdown {.dropdown-list { display: none;important; } } .multiselect-dropdown {.dropdown-list { display: none;important; } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 ng-multiselect-dropdown 在 angular 中将选择选项设为默认选择? - How to make a select option as default selected in angular using ng-multiselect-dropdown? 单击时自动聚焦 ng-multiselect-dropdown 的过滤字段 - Focus Filterfield of ng-multiselect-dropdown automatically when clicked angular ng-multiselect-dropdown 获取 id - angular ng-multiselect-dropdown get id 为什么在 angular6 的 ng-multiselect-dropdown 中未定义 idField? - Why idField is undefined in ng-multiselect-dropdown in angular6? 有没有办法在 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 如何使用jQuery从多选下拉列表中打印选定的值? - how to print selected values from multiselect dropdown list using jquery? 不选择时的角度下拉式传递值? - Angular dropdown passing values when i am not select? 如果选择了另一个选择下拉列表中的一个选项,如何显示选择下拉列表 - How do I display a select dropdown list when one option on another select dropdown is selected 有什么方法可以在 ng-multiselect-dropdown 插件的搜索框中检测或添加按键/点击事件 - Is there any way to detect or add an on-keypress/click event in search box of ng-multiselect-dropdown plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM