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

    selector: '[appChbgcolor]'
export class ChangeBgColorDirective {

    constructor(private el: ElementRef, private renderer: Renderer) {

    ChangeBgColor(color: string) {

        this.renderer.setElementStyle(this.el.nativeElement, 'color', color);
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter