Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

angular custom directive

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

@Directive({
  selector: '[appHighlight]'
})
export class HighlightDirective {
    constructor(private el: ElementRef) {
       this.el.nativeElement.style.backgroundColor = 'yellow';
    }
}
//To create a directive, use the CLI command
//ng g directive <name> [options]
Source by angular.io #
 
PREVIOUS NEXT
Tagged: #angular #custom #directive
ADD COMMENT
Topic
Name
2+8 =