All files / src/app/shared/directives autofocus.directive.ts

100% Statements 11/11
66.67% Branches 4/6
100% Functions 3/3
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1898x   98x         98x 185x   98x 174x 174x 174x     98x  
import { AfterViewInit, Directive, ElementRef } from '@angular/core';
 
import * as _ from 'lodash';
 
@Directive({
  selector: '[autofocus]' // tslint:disable-line
})
export class AutofocusDirective implements AfterViewInit {
  constructor(private elementRef: ElementRef) {}
 
  ngAfterViewInit() {
    const el: HTMLInputElement = this.elementRef.nativeElement;
    Eif (_.isFunction(el.focus)) {
      el.focus();
    }
  }
}