I would like to dynamically generate a string of classes based on the @Inputs to my Component.
I want these classes to be applied to the element that was selected by the Component, not any child elements of the Component.
Let's say I have a simple Component:
@Component({
selector: 'responsive-table-column',
templateUrl: `<div #responsiveTableCell >
<ng-content></ng-content>
</div>`
})
export class ResponsiveTableColumn {
private A:string = "";
private B:string = "";
@Input()
get a(){
return this.A;
}
set a(val:any){
this.A = val;
}
@Input()
get b(){
return this.B;
}
set b(val:any){
this.B = val;
}
getClassName(){
//Do something to create class names
return "classes";
}
}
I would like to apply the generated class names to my <responsive-table-column> element that has been selected by my component.
How can I access this element? Replace isn't supported, otherwise I would place it on #responsiveTableCell.
Essentially, this is what I would like to see:
<responsive-table-column class="{{getClassName()}}" >
<div #responsiveTableCell >
<ng-content></ng-content>
</div>
</responsive-table-column>