Created
June 30, 2022 04:11
-
-
Save NathanWalker/e2cb712514e81b984a8381400e27437f to your computer and use it in GitHub Desktop.
Angular Directive Sample
This file contains hidden or 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
import { Directive, ElementRef, inject } from "@angular/core"; | |
@Directive({ | |
selector: "[appHighlight]", | |
}) | |
export class HighlightDirective { | |
private el = inject(ElementRef); | |
constructor() { | |
this.el.nativeElement.style.backgroundColor = "yellow"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment