Last active
July 1, 2017 05:52
-
-
Save karthikchintala1/36cccdd875db084aa3939c7266a051c8 to your computer and use it in GitHub Desktop.
Attribute directives in Angular 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Directive is imported to provide the functionality of @Directive decorator | |
import { Directive, ElementRef } from '@angular/core' | |
@Directive({ selector: '[colorMe]'}) | |
export class ColorDirective { | |
//ElementRef is used to access the DOM element | |
constructor(private el: ElementRef) { | |
el.nativeElement.style.color = 'red'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment