Dartfrog Imi
Dartfrog Imi

Reputation: 529

How to disable ion-select using typescript. ionic 2

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

<ion-item>       
      <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>                 
          </ion-select>
  </ion-item>

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

In my type script file

  disableSelector:boolean

    constructor(){
       this.disableSelector = true;
    }

here is in the html file

disabled = "disableSelector"

totally cannot work at all

best Rgds, frog

Upvotes: 1

Views: 13035

Answers (1)

micronyks
micronyks

Reputation: 55443

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

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

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

           <ion-option value="ptype"                  //<<< removed {{}} braces.
                      *ngFor="let ptype of PropTypeArray">
                             {{ptype}}
          </ion-option>    
       ...             
 </ion-item>

Upvotes: 7

Related Questions