Ade Owolaike
Ade Owolaike

Reputation: 77

Value in input field will not display in ionic

I prefilled ion-input with a value but it is not displaying. I am new to ionic but I understand little of it concepts.

Here is what I tried.

.ts

async getSimData() {
    try {
      let simPermission = await this.sim.requestReadPermission();
      if (simPermission == "OK") {
        let simData = await this.sim.getSimInfo();
        this.simInfo = simData;
        this.cards = simData.cards;

      }
    } catch (error) {
      console.log(error);
    }
  }

html

 <ion-card  *ngFor= "let card of cards" >
    <ion-card-content>
      <ion-list> 
        <ion-item>
      <ion-input type="number" name="phone" value="{{ card.phoneNumber }}" #phone  disabled="true"></ion-input>
    </ion-item> 
      </ion-list>
    </ion-card-content>
  </ion-card>

How can I make this appear in the ion-input?

Upvotes: 1

Views: 642

Answers (1)

Praveen Patel
Praveen Patel

Reputation: 347

you can also use with ngModel, i checked your code it is also working with value.

In below code both are working, check this : https://stackblitz.com/edit/ionic-eu7tcl

<ion-card  *ngFor= "let card of cards" >
    <ion-card-content>
      <ion-list> 
        <ion-item>
      <ion-input type="number" name="phone" [(ngModel)]="card.phoneNumber" #phone  disabled="true"></ion-input>
      <ion-input type="number" name="phone" value="{{ card.phoneNumber }}" #phone  disabled="true"></ion-input>
    </ion-item> 
      </ion-list>
    </ion-card-content>
  </ion-card>

Upvotes: 1

Related Questions