Tag Archives: directives

How it works: Angular Directives

Angular directives are custom attributes for elements. It allows you to manipulate the element.

import { Directive, ElementRef } from '@angular/core';

@Directive({ selector: '[appHighlight]' })
export class HighlightDirective {
    constructor(el: ElementRef) {
       el.nativeElement.style.backgroundColor = 'yellow';
    }
}

Continue reading

Advertisements