简体   繁体   English

如何在Angular2中禁用多选下拉菜单

[英]How to disable multi select dropdown in angular2

I have used angular2 dropdown multi-select using below code 我已经使用下面的代码使用angular2下拉多选

 <ss-multiselect-dropdown [options]="myOptions" name="pack" [texts]="myTexts" [settings]="mySettings" [(ngModel)]="model.selectedPackValue"  [disabled]="canViewData">

But I can not able to disable this dropdown when my 'canViewData' is true 但是当我的'canViewData' 为true时,我无法禁用此下拉菜单

Then how to disable it ? 那么如何禁用它呢?

I found my solution as including below code in my multiselectdropdown.ts 我发现我的解决方案在multiselectdropdown.ts中包含以下代码

At 117 line add @Input() disable: string; 在117行添加@Input()disable:string;

and also add attribute to button at 76 line [disabled]="disable" 并将属性添加到按钮的第76行[disabled] =“ disable”

Now the below code in my template works fine.. 现在,我模板中的以下代码可以正常工作。

<ss-multiselect-dropdown [options]="myOptions" name="pack" [texts]="myTexts" [settings]="mySettings" [(ngModel)]="model.selectedPackValue"  [disable]="canViewData">

(and also above all changes are applied to multiselectdropdown.js) (而且首先,所有更改都将应用于multiselectdropdown.js)

Your are using some plugin 您正在使用一些插件

I think this is the one https://github.com/softsimon/angular-2-dropdown-multiselect 我认为这是一个https://github.com/softsimon/angular-2-dropdown-multiselect

Go to your node_modules folder from your solution and find the file 'multiselect-dropdown.ts' 从解决方案转到您的node_modules文件夹,然后找到文件“ multiselect-dropdown.ts”

https://github.com/softsimon/angular-2-dropdown-multiselect/blob/master/src/multiselect-dropdown.ts https://github.com/softsimon/angular-2-dropdown-multiselect/blob/master/src/multiselect-dropdown.ts

At 117 line add 在117行处添加

@Input() disable: boolean;

At 76 add attribute to button 在76向按钮添加属性

[disabled]="disable"

Now try the below code in your template this may help 现在在您的模板中尝试以下代码,这可能会有所帮助

<ss-multiselect-dropdown [options]="myOptions" name="pack" [texts]="myTexts" [settings]="mySettings" [(ngModel)]="model.selectedPackValue"  [disable]="canViewData">

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM