1

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?

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.