Dartfrog Imi Dartfrog Imi - 1 year ago 272
TypeScript Question

How to disable ion-select using typescript. ionic 2

I can disable ion-select using disable attribute like the following:

<ion-label stacked>Property Type</ion-label>
<ion-select [(ngModel)]="propType" (ionChange)="ionChanger()" disabled="true" >
<ion-option value="{{ptype}}" *ngFor="let ptype of PropTypeArray">{{ptype}}</ion-option>

How can i disable from typescript file? I tried the following command but no luck

In my type script file


this.disableSelector = true;

here is in the html file

disabled = "disableSelector"

totally cannot work at all

best Rgds,

Answer Source

You are using disableSelector variable so you need to use it with [disabled] property binding as shown below,

      <ion-label stacked>Property Type</ion-label>
          <ion-select [(ngModel)]="propType" 

                      [disabled]="disableSelector" >  //<<< This is required.

           <ion-option value="ptype"                  //<<< removed {{}} braces.
                      *ngFor="let ptype of PropTypeArray">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download