Angular8.0 Failed to execute 'setAttribute' on 'Element':

Angular 8.0

ERROR DOMException: Failed to execute 'setAttribute' on 'Element': '#imageSlider' is not a valid attribute

实现在类中引用模板功能,代码片断如下:

AppComponent.html
`<app-image-slider
[sliders]="imageSliders" #imageSlider>
</app-image-slider>
`
AppComponent.ts
`
export class AppComponent {
@ViewChild('imageSlider', {static: true}) imgSlider: ImageSliderComponent;
`

错误信息如下:(查询很多此类错误一般是拼写错误,但未找到)
2019-11-07 11-02-07 的屏幕截图.png

阅读 2.1k
1 个回答

应该是个英文半角的 #,不是全角的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进