Multiple components match node with tagname app-lobby

后端 未结 7 1109
刺人心
刺人心 2021-02-14 05:51

the code was running fine on angular version 8.3.4 but when i updated it to the latest version of angular ( 9 ) i got the following error

following is t

7条回答
  •  隐瞒了意图╮
    2021-02-14 06:38

    This error actually has less to do with the tagname app-lobby. I encountered this error when I applied multiple component selector on a html tag.

    For example: Component 1

    @Component({
        ...
        selector: '[my-tooltip]',
        ...
    })
    

    Component 2

    @Component({
        ...
        selector: '[my-button]',
        ...
    })
    

    Notice that both of them are angular component yet having a selector like attribute directive.

    When you apply both of them on the same tag like below:

    
    

    Then angular complains about applying 2 components on a single tag. In this case it will complain about button tag, like: Error: Multiple components match node with tagname button

    The solution would be not to use multiple component selector on a single element.

提交回复
热议问题