import { Directive , ElementRef , Input , Renderer2 } from '@angular/core' ; @ Directive ( { selector : '[appBanner]' } ) export class BannerDirective { @ Input ( ) set appBanner ( value ) { if ( value ) { this . renderer . setStyle ( this . elementRef . nativeElement , 'background' , value ) ; } } @ Input ( ) set color ( value ) { if ( value ) { this . renderer . setStyle ( this . elementRef . nativeElement , 'color' , value ) ; } } constructor ( private elementRef , private renderer ) { renderer . addClass ( elementRef . nativeElement , 'banner' ) ; } }