Commit 7a2c73f0 authored by dev0tion's avatar dev0tion

Add focus directive

parent c9c92c37
import { AutoFocusDirective } from './auto-focus.directive';
describe('AutoFocusDirective', () => {
it('should create an instance', () => {
const directive = new AutoFocusDirective();
expect(directive).toBeTruthy();
});
});
import { Directive, Renderer, ElementRef, OnInit } from '@angular/core';
@Directive({
selector: '[myAutoFocus]'
})
export class AutoFocusDirective implements OnInit {
constructor(private renderer: Renderer, private elementRef: ElementRef) { }
ngOnInit() {
this.renderer.invokeElementMethod(
this.elementRef.nativeElement, 'focus', []
);
}
}
import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CoinNotationPipe } from './pipes/coin-notation.pipe';
import { AutoFocusDirective } from './directives/auto-focus.directive';
@NgModule({
imports: [CommonModule],
declarations: [CoinNotationPipe],
exports: [CoinNotationPipe]
declarations: [CoinNotationPipe, AutoFocusDirective],
exports: [CoinNotationPipe, AutoFocusDirective]
})
export class SharedModule {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment