Home > Net >  Insert custom value as first item in ngselect angular package
Insert custom value as first item in ngselect angular package

Time:11-02

I am using https://www.npmjs.com/package/@ng-select/ng-select for autocomplete cum dropdown. How to insert something like "Please select" as the very first element in it.

i implemented the package as follow. This is my html file

<ng-select  [items]="items"
           bindLabel="Name"
           autofocus
           bindValue="Id"
           (close)="close()"
           (clear)="clear()"
           placeholder="Select people"
           [(ngModel)]="selectedId">
</ng-select>

CodePudding user response:

From there demo page, use placeholder="Select age"

<ng-select #agesSelect [items]="ages"
   [selectOnTab]="true"
   bindValue="value"
   labelForId="age"
   (ngModelChange)="showConfirm(confirmation)"
   placeholder="Select age"
   formControlName="age">

Code: https://stackblitz.com/run?file=src/forms-single-select-example.component.html

Demo: https://ng-select.github.io/ng-select#/forms

  • Related