P Rane
P Rane

Reputation: 306

ng-Select drop down disable and disable or remove close button

I used ng-select option menu but i want to disable or remove it's close button how to do this. here i used code `

<ng-select id="CompanyID"  [(ngModel)]="CompanyId" placeholder="-- select an option --">
 <ng-option disabled selected value> -- select an option -- </ng-option>
 <ng-option *ngFor="let company of Company" [value]="company.Company_ID" [disabled]="true">{{company.Name}}</ng-option>
</ng-select>`

Upvotes: 1

Views: 17292

Answers (3)

Akitha_MJ
Akitha_MJ

Reputation: 4294

<ng-select [clearable]="false">
</ng-select>

Just add the attribute [clearable]="false"

Upvotes: 2

alberto montalesi
alberto montalesi

Reputation: 1028

Best way is to use [clearable]="false" so that you don't have to use css.

<ng-select [clearable]="false">
</ng-select>

Upvotes: 10

yuva
yuva

Reputation: 3328

How I would do is, create a CSS class called no-clear -

.no-clear.ng-select .ng-clear-wrapper {
  display: none;
}

Then use that class in your ng-select template,

<ng-select class="no-clear"
           [items]="youtData"
           [(ngModel)]="yourModel">
</ng-select>

Or you can also use [clearable]="false" directive.

Upvotes: 3

Related Questions