I\'m trying to create a button component in angular 2. At the host I have to set a dynamically generated css classname. (depending on binded property)
\'[ngClass]\'
Thanks to Günter I've found the solution. This is his code but cleaned for anyone who can use it in the future.
private color_: string;
@Input()
set color(value: string) {
this.color_ = value;
this.renderer.setElementClass(this.elementRef, 'md-' + this.color_, true);
}
get color(): string {
return this.color_;
}
constructor(private elementRef: ElementRef, private renderer: Renderer) { }