如何在ionic2中执行只读或禁用?

Nar*_*yas 2 ionic2 angular

实际上我试图将一个字段设置为只读或禁用为ionic2形式:

<ion-item>
    <ion-label fixed>Category <ion-icon name="ios-arrow-forward"></ion-icon></ion-label>
    <ion-input type="text" [disabled]="false" id="category_name" class="form-control" formControlName="category_name" (click)="category()" [(ngModel)]="category_name"></ion-input>
</ion-item>
Run Code Online (Sandbox Code Playgroud)

我也用[readonly] ="false".

我知道这也是一个问题,git也存在问题:

https://github.com/driftyco/ionic/issues/6408 ..

所以任何帮助我如何解决它.

Bir*_*chi 6

我用它来解决Ionic 2:

  In .ts file:
  ------------
  isReadonly() {
    return this.isReadonly;   //return true/false 
  }


  In .html file:
  --------------
  <ion-input type="text"  [readonly]="isReadonly()"></ion-input>
Run Code Online (Sandbox Code Playgroud)