Class is using Angular features but is not decorated. Please add an explicit Angular decorator

前端 未结 3 2326
暖寄归人
暖寄归人 2020-12-20 11:36

I have some components like CricketComponent, FootballComponent, TennisComponent etc. All These Classes have some common properties :-

3条回答
  •  不知归路
    2020-12-20 12:12

    While the accepted answer is correct in using @Component, one minor downside is that it requires all constructor argument types to be resolvable by DI. So if your base class constructor takes a constant/literal - say, an enum - as a flag, you're going to have to set up a corresponding DI provider/token just to get it to compile.

    You can however also resolve NG2007 using the @Directive decorator instead, which doesn't require DI compatibility

提交回复
热议问题