Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform readonly or disabled in ionic2?

Tags:

angular

ionic2

Actually i am trying to set a field as readonly or disabled in ionic2 form as:

<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>

I also used [readonly]="false".

I know it's an issue with also there are issues on git :

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

So any help how i could fix it out.

like image 798
Narendra Vyas Avatar asked Oct 28 '25 15:10

Narendra Vyas


1 Answers

I have used this to solve in Ionic 2:

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


  In .html file:
  --------------
  <ion-input type="text"  [readonly]="isReadonly()"></ion-input>
like image 182
Biranchi Avatar answered Oct 31 '25 05:10

Biranchi