import { Directive , ElementRef , OnInit , Renderer2 } from '@angular/core' ; @ Directive ( { selector : '[autocomplete-off]' } ) export class AutocompleteOffDirective implements OnInit { private readonly _chrome = navigator . userAgent . indexOf ( 'Chrome' ) > - 1 ; constructor ( private readonly _renderer , private readonly _el ) { } ngOnInit ( ) { if ( this . _chrome ) { if ( this . _el . nativeElement . hasAttribute ( 'autocomplete-off' ) ) { /**
                 * disabled autocomplete for form
                 */ setTimeout ( ( ) => { this . _el . nativeElement . setAttribute ( 'autocomplete' , 'off' ) ; } ) ; /**
                 * disabled autocomplete for all inputs inside form
                 */ const inputs = Array . prototype . slice . call ( this . _el . nativeElement . querySelectorAll ( 'input' ) ) ; inputs . forEach ( ( element ) => { this . _renderer . setAttribute ( element , 'autocomplete' , 'off' ) ; this . _renderer . setAttribute ( element , 'autocorrect' , 'off' ) ; this . _renderer . setAttribute ( element , 'autocapitalize' , 'none' ) ; this . _renderer . setAttribute ( element , 'spellcheck' , 'false' ) ; } ) ; } } } }