Angular 4 cannot find name 'ViewChild'

Soufiane Touil picture Soufiane Touil · Oct 18, 2017 · Viewed 18.2k times · Source

I have this strange error and didn't find anything similar to it .. I'm using ng2-canvas-whiteboard component for a drawing canvas on my website, everything's working perfectly except when i try to get reference to that canvas using :

@ViewChild('canvasWhiteboard') canvasWhiteboard: CanvasWhiteboardComponent;

as the official docs suggested, i'm getting this error :

Failed to compile.

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

Any suggestions ? Thank you

Answer

Pankaj Parkar picture Pankaj Parkar · Oct 18, 2017

You forgot to import ViewChild before using it

import { ViewChild } from '@angular/core'