如何使用打字稿禁用离子选择.离子2

Dar*_*Imi 1 typescript ionic2 angular

我可以使用disable属性禁用ion-select,如下所示:

<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>
Run Code Online (Sandbox Code Playgroud)

如何禁用typescript文件?我尝试了以下命令,但没有运气

在我的类型脚本文件中

  disableSelector:boolean

    constructor(){
       this.disableSelector = true;
    }
Run Code Online (Sandbox Code Playgroud)

这是在html文件中

disabled = "disableSelector"
Run Code Online (Sandbox Code Playgroud)

完全不能工作

最好的Rgds,青蛙

mic*_*yks 6

您正在使用disableSelector变量,因此您需要将其与[disabled]属性绑定一起使用,如下所示,

<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>
Run Code Online (Sandbox Code Playgroud)