Angular 4找不到名字'ViewChild'

时间:2017-10-18 18:16:06

标签: angular find viewchild

我有这个奇怪的错误,并没有发现任何类似的东西.. 我在我的网站上使用ng2-canvas-whiteboard组件作为绘图画布,除了当我尝试使用以下方式引用该画布时,一切都正常工作:

@ViewChild('canvasWhiteboard') canvasWhiteboard: CanvasWhiteboardComponent;

正如官方文档建议的那样,我收到了这个错误:

Failed to compile.

e:/frontend/src/app/components/user/dashboard/dashboard.component.ts (15,2): Cannot find name 'ViewChild'.

有什么建议吗?谢谢

1 个答案:

答案 0 :(得分:29)

您在使用之前忘记导入ViewChild

import { ViewChild } from '@angular/core'