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

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

I have DOM that looks something like this:


    
    ...

         


        
11条回答
  •  青春惊慌失措
    2020-12-15 15:56

    The key is /deep/ keyword:

        :host /deep/ router-outlet + project {
            display: block;
            border: 10px solid black;
        }
    

    This works without any extra configurations.

    :host /deep/ router-outlet + * for whatever component dynamically created by Angular Router.

    Edited 2018/3/5:

    Since Angular 4.3.0 made /deep/ deprecated, its suggested alternative is ::ng-deep. And there were a long discussion about this.

提交回复
热议问题