Is it possible to add a dynamic class to host in Angular 2?

后端 未结 7 1960
眼角桃花
眼角桃花 2021-01-01 15:47

I know that in Angular2 I can add a class \'red\' to a component\'s selector element by doing this:

@Component({
    selector: \'selector-el\',
    host: {
          


        
7条回答
  •  生来不讨喜
    2021-01-01 16:04

    I did it in this way. Maybe someone will come in handy

    @HostBinding('class') get hostClasses() {
        return `some-class ${this.dinamicOne} ${this.disabled ? 'disabled' : ''}`;
    }
    

提交回复
热议问题