Skip to content

Instantly share code, notes, and snippets.

@hiepxanh
Created August 6, 2019 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiepxanh/b5b1eb1fdfd1240ea4e0145f4e543e78 to your computer and use it in GitHub Desktop.
Save hiepxanh/b5b1eb1fdfd1240ea4e0145f4e543e78 to your computer and use it in GitHub Desktop.
Fix Auto Fill Chrome with Angular 8 and Ionic 4
// <ion-input (change)="fixAutoFill($event, 'password')" #passwordInput autocomplete="off" formControlName="password" type="password"></ion-input>
// <ion-input (change)="fixAutoFill($event, 'username')" #usernameInput autocomplete="off" type="text" formControlName="username"></ion-input>
fixAutoFill(event, type) {
const value = event.target.value;
if (type === 'username') {
this.loginForm.patchValue({
username: value
}, {emitEvent: true, onlySelf: false});
} else {
this.loginForm.patchValue({
password: value
}, {emitEvent: true, onlySelf: false});
}
// console.log('after click', this.loginForm.value);
}
@ViewChild('usernameInput') usernameInput: IonInput;
@ViewChild('passwordInput') passwordInput: IonInput;
@johngrant
Copy link

Thanks for this! Appears to fix up autofill on my form and I can't see any adverse effects yet. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment