Mbsc-select will display first item in data when formControl value is empty


#1

I’m using mbsc-select like this:

<ion-item>
       <ion-label>Type</ion-label>
       <ion-input mbsc-select
                  [mbsc-data]="types"
                  formControlName="TYPE_ID"></ion-input>
</ion-item>

When formControl’s value is empty, mbsc-select will display the first item’s text in ion-input.Is it possible to display nothing? Thanks.


#2

To display nothing initially, you will need to add and empty value to your types. Optionally you can set the empty value to disabled, to prevent manual selection of the empty value:

  types: any = [
    { value: '', text: '', disabled: true },
    { value: 1, text: 'Type 1' },
    { value: 2, text: 'Type 2' },
    { value: 3, text: 'Type 3' },
    { value: 4, text: 'Type 4' },
  ];