类型'ElementRef'不是通用的 [英] Type 'ElementRef' is not generic

查看:145
本文介绍了类型'ElementRef'不是通用的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Angular 5中的Material Component处理一个项目.我确实更新了Visual代码,但不知道发生了什么.我遇到一个问题类型'ElementRef'不是通用的". 自从早上以来,我一直在这个问题上陷入困境.

I am working with a project using Material Component in Angular 5. I did update my Visual code but I don't know what happened. I am facing an issue "Type 'ElementRef' is not generic." I have been stuck on this issue since morning.

此行中的错误

Error in this line

_inputElement: ElementRef<HTMLInputElement>;
constructor(toggleGroup: MatButtonToggleGroup, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLInputElement>, _focusMonitor: FocusMonitor);

推荐答案

我认为问题可能出在如果您使用的是Angular Material 6,但仍使用Angular 5,那么您将收到此错误.当我安装Angular 5.x.x版本时,安装Angular Material 6 RC 12时会寻找Angular 6 Beta 0的对等依赖项.

I think the problem could be if your you are using Angular Material 6 but still Angular 5 then you will get this error. When installing Angular Material 6 RC 12 it's looking for a peer dependency for Angular 6 Beta 0 while I had a Angular 5.x.x version.

解决方案:

  1. 将Angular Material降级到Angular的相同主要版本(例如v5.x.x)
  2. 将Angular和Material升级到最新的RC版本,并在边缘享受生活. (例如v6.x.x RCx)

PS:他们在ng-conf 2018上宣布,从版本6开始,Angular,Angular Material和Angular CLI的所有版本号将保持同步,因此了解功能和兼容性将变得更加容易,希望您会成功.不会再有这个问题了.

PS: They announced at ng-conf 2018 that from version 6 onwards all the version numbers for Angular, Angular Material and Angular CLI will stay in sync so knowing what goes with what and compatibility will be much easier and hopefully you won't have this problem again.

这篇关于类型'ElementRef'不是通用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆