Skip to content

Instantly share code, notes, and snippets.

@debugmodedotnet
Created December 28, 2017 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debugmodedotnet/d63b06251fc751ca640ea7c3b502065c to your computer and use it in GitHub Desktop.
Save debugmodedotnet/d63b06251fc751ca640ea7c3b502065c to your computer and use it in GitHub Desktop.
import { Directive, ElementRef, Renderer } from '@angular/core';
@Directive({
selector: '[appChbgcolor]'
})
export class ChangeBgColorDirective {
constructor(private el: ElementRef, private renderer: Renderer) {
this.ChangeBgColor('red');
}
ChangeBgColor(color: string) {
this.renderer.setElementStyle(this.el.nativeElement, 'color', color);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment