Skip to content

Instantly share code, notes, and snippets.

@FrenchTechLead
Created May 20, 2020 02:07
Show Gist options
  • Save FrenchTechLead/773b63e4c786608c0ce9618936b99380 to your computer and use it in GitHub Desktop.
Save FrenchTechLead/773b63e4c786608c0ce9618936b99380 to your computer and use it in GitHub Desktop.
Angular directive to disable chrome's form autocomplete.
import { Directive, ElementRef } from '@angular/core';
@Directive({
selector: '[autocompleteOff]'
})
export class AutocompleteOffDirective {
constructor(private _el: ElementRef) {
this._el.nativeElement.setAttribute('autocomplete', 'off');
this._el.nativeElement.setAttribute('autocorrect', 'off');
this._el.nativeElement.setAttribute('autocapitalize', 'none');
this._el.nativeElement.setAttribute('spellcheck', 'false');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment