It allows us to create a division or section in a template without introducing a new HTML element.
It is not render in the DOM, but content inside it is rendered.
It is just a syntax element , which is rendered as a comment.
Custom Directives
@Directive({
selector: '[appHoverEffect]'
})
<tr *ngFor="let employee of employees;let i =index;" appHoverEffect [mouseEnterColor]="'gray'">
constructor(private _el : ElementRef) { }
@Input() mouseEnterColor : string;
@HostListener('mouseenter') onMouseEnter() {
this.hoverEffect(this.mouseEnterColor);
}
private hoverEffect(color){
this._el.nativeElement.style.backgroundColor = color;
}
No comments:
Post a Comment