So i have inputs on several pages and i fill them in when the data is loaded (from native storage, http, sqlite) the placeholder text doesn’t always dissapear automatically. If i press anywhere on the screen it is immediately hidden. Is there something that can be done to redraw the fields or have them updated attached is a screenshot and also the code used to fill the form
<ion-item style="padding:75px 25px 0px 25px">
<ion-input type="text" value="" placeholder="{{ 'IPC ID or Username' | translate }}" [(ngModel)]="form.username" name="username" #ipcid (keyup)="formValid()" (keyup.enter)="ipcidNext()"></ion-input>
</ion-item>
this.nativeStorage.getItem("ipcid").then(
data => {this.form["username"] = data;},
error => console.error(error)
);
I should mention that this only happens in IOS, android devices have no problem. I found a solution but it is so hacky and there must be a more proper way of doing it. If i also set the value attribute for the element, and then setfocus() on the element it will go away. so right now i set the model varaible, then i set the value attribut and then i setfocus the element for each element on the page. I really hate doing this so if someone else has a better solution please speak up.
export class EditCustomerPage {
@ViewChild('namefield') nameInput;
@ViewChild('lastnamefield') lastnameInput;
@ViewChild('emailfield') emailInput;
@ViewChild('agefield') ageInput;
Name;
last_name;
email;
age;
constructor(public navCtrl: NavController, public navParams: NavParams, public scandatabase: ScanDatabaseProvider, public platform: Platform) {
}
ionViewWillEnter(){
this.lead_id = this.navParams.get("lead_id");
this.platform.ready().then(data => {
this.scandatabase.getLead(this.lead_id).then(data => {
var row = data.rows.item(0);
this.nameInput.value = row.name;
this.lastnameInput.value = row.last_name;
this.emailInput.value = row.email;
this.ageInput.value = row.age;
this.Name = row.name;
this.last_name = row.last_name;
this.email = row.email;
this.age = row.age;
this.nameInput.setFocus();
this.lastnameInput.setFocus();
this.emailInput.setFocus();
this.ageInput.setFocus();
})
});