import { Directive , Input , ElementRef } from '@angular/core' ; import { coerceBooleanProperty } from 'ngx-tethys/util' ; @ Directive ( { selector : 'input[thyAutofocus],textarea[thyAutofocus]' } ) export class ThyAutofocusDirective { private _autoSelect = false ; @ Input ( ) set thyAutoSelect ( value ) { this . _autoSelect = coerceBooleanProperty ( value ) ; } @ Input ( ) set thyAutofocus ( value ) { if ( coerceBooleanProperty ( value ) !== false ) { setTimeout ( ( ) => { this . elementRef . nativeElement . focus ( ) ; if ( this . _autoSelect && this . elementRef . nativeElement . select ) { this . elementRef . nativeElement . select ( ) ; } } ) ; } } constructor ( private elementRef ) { } }