How can I dynamically add a class to the host component of this angular component?
@Component({
selector: 'test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class TestComponent implements OnInit {
@HostBinding('className') componentClass: string;
@Input() name: string;
constructor() {}
ngOnInit(): void {
this.componentClass = this.name ? `test-icons test-icons-${this.name}` : '';
}
}
The current setup overrides any additional classes I try to add. For example, if I include:
<test-component class="custom-class-i-added" [name]="'icon']></test-component>
The "custom-class-i-added" disappears. Is there a way to dynamically add classes without overriding the existing ones?