Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable angular ng-select window

We are using ng-select in a project and I'm facing the problem that I can't disable the ng-select window. Is it possible to disable it with native code or do I need to find some custom solution?

  <ng-select 
    #changeowner
    class="custom-owner"
    [placeholder]="leagueOwner.full_name"
    [clearSearchOnAdd]="true"
    (change)="changeLeagueOwner($event)"
    [clearable]="false"
    [virtualScroll]="true"
    [items]="adminLeagueMembers"
    (scrollToEnd)="onAdminLoadScrollEnd()"
    bindLabel="full_name">
</ng-select>
like image 486
Bogdan Tushevskyi Avatar asked Jul 31 '18 11:07

Bogdan Tushevskyi


People also ask

How to disable ng-select in angular?

If you are using the Angular reactive form and trying to disable the ng-select using the following code then sorry it will not work in some case. If you are using formControlName then it will not work but work in [(ngModel)] case. The best way to do this is by using reactive form control.

How to disable value in ng-select?

The best way to do this is by using reactive form control. [readonly] boolean false no Set ng-select as readonly. Mostly used with reactive forms. adding [disabled]="true" did not work for me But setting [readOnly] to true did.


1 Answers

As stated in other responses you can use the option

[disabled]="booleanValue"

However you will need a formControlName value set as well as described here.

You would get:

<!-- test-component.html -->
<ng-select [disabled]="myDisabledCondition" formControlName="myFormControl" 
...>
</ng-select>
like image 189
Nasta Avatar answered Sep 30 '22 07:09

Nasta