Conditional styling on host element

前端 未结 4 2280
既然无缘
既然无缘 2021-02-19 07:04

I have a component that all it does is render , its something like this:

@Component({
     selector: \'my-comp\',
     host: ???,
     template: `
         

        
4条回答
  •  难免孤独
    2021-02-19 07:15

    You use the class and style prefix for this. Here is a sample:

    @Component({
      selector: 'my-comp',
      host: {
        '[class.className]': 'isChanged'
      },
      template: `
        
      `
    })
    export default class MyComp {
      @Input() title: string;
      public isChanged: boolean;
    }
    

    See the Günter's answer for more details:

    • ngClass in host property of component decorator does not work

提交回复
热议问题