angular - 带有 @Injectable() 的 Angular 9 BaseComponent
问题描述
在 Angular 8 中,我能够使用“@Injectable”属性创建基础组件(实际组件继承自的类)。Angular 9 编译器告诉我:
组件 YourComponent 从 BaseComponent 继承其构造函数,但后者没有自己的 Angular 装饰器。依赖注入将无法解析 BaseComponent 的构造函数的参数。向 BaseComponent 添加一个 @Directive 装饰器,或者向 RoleSelectDialogComponent 添加一个显式构造函数。
现在 Angular 9 做这些事情的方式是什么?这可行,但看起来有点hacky:
@Component({
selector: 'baseComponent',
template: 'no-ui'
})
解决方案
线索在消息中
Either add a @Directive decorator to BaseComponent
向它添加 @Directive() 应该可以解决问题。
我现在正在升级,我的基础组件自动添加了 @Directive() 装饰器。
推荐阅读
- java - 如何将输入转换为程序可以理解的方法
- css - 向下拉列表中添加动画样式
- php - 致命错误:未捕获的 ReflectionException:类“env”不存在
- python - 如何可视化分类频率差异
- flutter - Flutter Firestore 在模拟器上抛出 Google Playstore 异常
- css - 关于 wordpress 问题的粘性 CSS 问题,似乎不是溢出问题
- python - imdb 前 250 部电影刮板——如何仅从 2000 年及以后获得结果?
- linux - Mac 上的 golang unix.TCGETS 等价物
- r - 如何将 case_when 与整个数据框一起使用?
- c++ - 运行 gui.get 时读取访问冲突
("") 在 TGUI 中使用 sfml 后端