Js code does not work the before a one time click anywhere the page


#1

ionViewWillEnter() {
document.getElementById(‘login’).click();
}
signin() {
let input_user = (document.getElementById(‘input_user’) as HTMLInputElement).value;
let input_password = (document.getElementById(‘input_pass’) as HTMLInputElement).value;
this.credentials.email = input_user;
this.credentials.password = input_password;

this.authservice.login(this.credentials).then((res: any) => {
  if (....)
    this.navCtrl.setRoot('.....');
  else
    alert(...);
})

}


#2

Try using this
ionViewWillEnter() {
this.signin();
}


#3

:smiley: thank you :slight_smile:


#4

Is this for normal operation or some sort of testing? You shouldn’t be directly dealing with the DOM like this under normal operation.


#5

Okey. for my private app. we can say a kind of test.


#6

As long as you’re clear that this is a really unusual thing to be doing in Ionic apps. Angular provides a zillion more idiomatic ways of binding DOM elements to controller properties.