disable angular ng-select window

Bogdan Tushevskyi picture Bogdan Tushevskyi · Jul 31, 2018 · Viewed 27.6k times · Source

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>

Answer

Nasta picture Nasta · Jan 29, 2019

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>