Angular 4 cannot find the name 'ViewChild'

I have this strange error and have not found anything like it. I use the ng2-canvas-whiteboard component for a canvas on my website, everything works fine, except when I try to get a link to this canvas using:

@ViewChild('canvasWhiteboard') canvasWhiteboard: CanvasWhiteboardComponent;

as the official docs suggested, I get this error:

Failed to compile.

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

Any suggestions? Thanks you

+4
source share
1 answer

You forgot to import ViewChildbefore using it

import { ViewChild } from '@angular/core'
+12
source

Source: https://habr.com/ru/post/1687744/


All Articles