Module build failed: SyntaxError. cant use NavController


#1

Hello, i installed ionic 2 last week and i test a few things. Everything was okey.
Today i updated my npm and ionic2 and now i get an error:

i tells me that “nav: NavController” is a syntaxerror.

I dont know what happend. Can someone help.

ERROR in ./app/pages/home/home.js
Module build failed: SyntaxError: D:/Emre/Ionic/TestProject/tarihden/app/pages/h
ome/home.js: Unexpected token (13:20)
11 | export class HomePage {
12 |

13 | constructor (nav: NavController ) {
| ^
14 |
15 | this.nav = nav;
16 | this.myData = “Hallo Emre”;
at Parser.pp.raise (D:\Emre\Ionic\TestProject\tarihden\node_modules\babel-co
re\node_modules\babylon\index.js:1425:13)
at Parser.pp.unexpected (D:\Emre\Ionic\TestProject\tarihden\node_modules\bab
el-core\node_modules\babylon\index.js:2905:8)
``


#2

I’m getting the exact same problem as the OP. I just created a new project and added a the constructor with nav param to a single tab and it won’t compile.


#3

I had the exact same problem. I went to the sidemen template to see how the navigation works and found this

export class Page1 {
static get parameters(){
return [[NavController],[Http]];
}
constructor(nav, http) {
this.nav = nav;
this.http = http;

Now my navigation works again


#4

That’s the difference between the TS version and the JS one, the Ionic 2 docs are made for the TS version soo…