I have used autocomplete="false" ("/nope/no /new-password").
In both formControl and FromGroup even I have tried using directive by using native element and setting the property as false.
But still, I do not have the solution for disabling the autocomplete/autofill.
Is it possible to change the browser level setting as turn off auto Suggestions/autofill by using our script?
I have tried a lot, but I can't. Here I have attached the code which I have using both the form level and directive level.
<form [formGroup]="loginForm" autocomplete="off">
<input matInput placeholder="Username" formControlName="username" autocomplete="off">
<input matInput type="password" formControlName="password" autocomplete="new-password">
</form>
import { Directive, ElementRef } from '@angular/core';
@Directive({
selector: '[autocompleteOff]'
})
export class AutocompleteOffDirective {
constructor(private _el: ElementRef) {
let w: any = window;
let isChrome = w.chrome;
if (isChrome) {
this._el.nativeElement.setAttribute('autocomplete', 'off');
this._el.nativeElement.setAttribute('autocorrect', 'off');
this._el.nativeElement.setAttribute('autocapitalize', 'none');
this._el.nativeElement.setAttribute('spellcheck', 'false');
}
}
}