Reputation: 8065
I'm trying to import NavController in a constructor from a class, following the docs/examples:
import {NavController} from "ionic-framework/ionic";
//some other code
export class SignUp {
constructor(nav: NavController) {
this.nav = nav;
}
}
and the console outputs: Uncaught Error: Cannot find module "./pages/signup/signup"
if I remove the constructor, there's no error.
It seems there's some sort of error in the construct() but I can't find out, I have seen differents examples and the piece of code I wrote is the same from them. Any idea?
EDIT: on the CLI I saw this error:
ERROR in ./app/pages/signup/signup.js
Module build failed: SyntaxError: app/pages/signup/signup.js: Unexpected token (10:16)
8 | export class SignUp {
9 |
> 10 | constructor(nav: NavController) {
| ^
11 | this.nav = NavController;
12 | console.log(this.nav)
13 | }
Upvotes: 1
Views: 1342
Reputation: 46
Try this:
export class Signup {
static get parameters() {
return [[NavController]];
}
constructor(nav) {
this.nav = nav;
...
}
}
Upvotes: 2
Reputation: 2719
Your syntax is wrong. You should have this.nav = nav
in the constructor, or just put public
before nav in the parameters like:
constructor(public nav: NavController) {
}
and you wont ne
Upvotes: 3