Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make ion-input disabled?

How can I disable ion-input?

<ion-input type="text"></ion-input>

I'm new at Ionic Framework, it is rather similar to HTML, but there is no property for attribute to disable it like:

.prop("disabled", true)

like image 251
Sveta Antrapovich Avatar asked Dec 15 '22 03:12

Sveta Antrapovich


2 Answers

Ionic 2:

  1. Static property:

     <ion-input disabled="true" type="text"></ion-input>
    
  2. Dynamically:

    <ion-input disabled="{{isDisabled}}" type="text"></ion-input>
    

    After in the component(.ts file):

    private isDisabled: boolean=false;
    
like image 116
Julianesten Avatar answered Dec 20 '22 16:12

Julianesten


disabled in small characters, it works on the boolean mechanism. bind the object of true and false so you will get the result.

<ion-input disabled="{{inputDisabled}}" [(ngModel)]="drill_plus" placeholder="Drill Plus" type="number"></ion-input>

your ts export class

inputDisabled: boolean = false;

condition

this.inputDisabled = true;

works for me. try this, hope you will get the answer.

like image 39
Mihir Patel Avatar answered Dec 20 '22 17:12

Mihir Patel