How to set default value in ionic input?

I want to set a default value in ionic input … please help


<ion-label floating>{{''|translate}}</ion-label>
        <ion-input type="text" formControlName="user_email"></ion-input>

default mail like

2 ways.

  1. set the value=""
  2. use placeholder attribute on ion-input. ie. placeholder=""

its get from something formControlName="user_email" so value="" not working … and i can not remove formControlName="user_email" … because when i try to remove this … my app not working!!!

here is my .ts code }); translate.get('address.location').subscribe(trans => this.trans = trans); this.formAddress ={ billing_first_name: ['', Validators.required], billing_address_1: ['', Validators.required], billing_phone: ['', Validators.compose([Validators.required, CoreValidator.isPhone])],user_email: [’’],shipping_first_name: [''], shipping_address_1: [''], }); this.getData(); please tell how set defult value from user_email: [''],

Dont set a value like that.
Set a value like it used to be in Ionic with NgModel

.ts file

// Define before your constructor as:
sDefaultEmail   :  string;

    sDefaultEmail = '';

.html file

1 Like

bind the input value with a variable and initialize it with some value
.ts file
email:string=‘’ before the constructor of page
and bind it with ngModel

<ion-input type=“email” [(ngModel)] = “email”>

and also use input type email instead of text