File

projects/rebirth-ng/src/lib/common/auto-focus.directive.ts

Implements

AfterViewInit

Metadata

selector [reAutoFocus]

Index

Methods
Inputs

Constructor

constructor(elementRef: ElementRef)
Parameters :
Name Type Optional
elementRef ElementRef no

Inputs

reAutoFocus

Type: boolean

Methods

ngAfterViewInit
ngAfterViewInit()
Returns : void
import { Directive, Input, ElementRef, AfterViewInit } from '@angular/core';

@Directive({
  selector: '[reAutoFocus]',
})
export class AutoFocusDirective implements AfterViewInit {

  @Input('reAutoFocus') autoFocus: boolean;

  constructor(private  elementRef: ElementRef) {
  }

  ngAfterViewInit(): void {
    if (this.autoFocus && this.elementRef.nativeElement.focus) {
      this.elementRef.nativeElement.focus();
    }
  }
}

results matching ""

    No results matching ""