Created
August 6, 2019 07:08
-
-
Save hiepxanh/b5b1eb1fdfd1240ea4e0145f4e543e78 to your computer and use it in GitHub Desktop.
Fix Auto Fill Chrome with Angular 8 and Ionic 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! Appears to fix up autofill on my form and I can't see any adverse effects yet. :)