Mansi Kalola
Mansi Kalola

Reputation: 159

How to disable multi select dropdown in angular2

I have used angular2 dropdown multi-select using below code

 <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

Then how to disable it ?

Upvotes: 0

Views: 11240

Answers (2)

Mansi Kalola
Mansi Kalola

Reputation: 159

I found my solution as including below code in my multiselectdropdown.ts

At 117 line add @Input() disable: string;

and also add attribute to button at 76 line [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)

Upvotes: 3

Habeeb
Habeeb

Reputation: 1040

Your are using some plugin

I think this is the one https://github.com/softsimon/angular-2-dropdown-multiselect

Go to your node_modules folder from your solution and find the file 'multiselect-dropdown.ts'

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

At 117 line add

@Input() disable: boolean;

At 76 add attribute to button

[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">

Upvotes: 1

Related Questions