viewChild unexpected token

Hello guys,

I am facing a problem with ViewCHild. If you have any idea thanks.

I am trying to compile using the example of Slide to go to another slide:

But when I put this line of code:

@ViewChild('mySlider') slider: Slides;

I get the error below:

**s/config/config-opcoes.js: Unexpected token (10:31)**
**   8 | export class ConfigOpcoesPage {**
**   9 | **
**> 10 |   @ViewChild('mySlider') slider: Slides;**

Basic problem with the “:”, I read in other post but they just resolve to constructor

Thank you in advanced

1 Like

You are writing TypeScript where JavaScript is expected. Either write JavaScript or create a TypeScript project.

Even if he is using Typescript where Javascript is expected. How can you work around the @ViewChild, I see no way to do this with ES6. All examples of Angular2 and Ionic2 using TypeScript. Some posts are saying to use ES7 annotations, but Im not sure if this is enough for @ViewChild to work.