How to apply css class to a component element when it's created by router-outlet?

前端 未结 11 1438
南旧
南旧 2020-12-15 15:41

I have DOM that looks something like this:


    
    ...

         


        
11条回答
  •  天涯浪人
    2020-12-15 16:01

    Assuming you always want the class applied to this component, you can use host in your component metadata:

    @Component({
      selector:'project',
      host: {
          class:'classYouWantApplied'
      }
    })
    

    Resulting in:

    
        
        ...
    
    

提交回复
热议问题