Skip to content

Instantly share code, notes, and snippets.

@samlam
Last active June 23, 2017 16:08
Show Gist options
  • Save samlam/f487b2048a6968fc4f36dad7e137f031 to your computer and use it in GitHub Desktop.
Save samlam/f487b2048a6968fc4f36dad7e137f031 to your computer and use it in GitHub Desktop.
Angular 4+ Renderer2 example
import { Component,Renderer2 } from '@angular/core';
@Component({
selector:'app-root',
template:``
})
export class AppComponent{
value=true;
constructor(private renderer:Renderer2){
}
onChangeBackground(element:HTMLElement){
this.renderer.setStyle(element,'background-color','blue');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment