1 import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';
3 import * as _ from 'lodash';
6 selector: '[autofocus]' // tslint:disable-line
8 export class AutofocusDirective implements AfterViewInit {
11 constructor(private elementRef: ElementRef) {}
14 const el: HTMLInputElement = this.elementRef.nativeElement;
15 if (this.focus && _.isFunction(el.focus)) {
21 public set autofocus(condition: any) {
22 if (_.isBoolean(condition)) {
23 this.focus = condition;
24 } else if (_.isFunction(condition)) {
25 this.focus = condition();