javascript - IONIC2 - Syntax Error when ionic serve -


i don't know did wrong, says syntax error codes copy pasted official ionic2 docs.

syntaxerror: d:/manson/arts/ionic/ionictodo2/app/pages/list/list.js: unexpected token (14:23) while parsing file: d:\manson\arts\ionic\ionictodo2\app\pages\list\list.js

for full code click here.

    constructor(nav: navcontroller) { 

it looks you're using types typescript, while code in plain javascript file (.js). nav: navcontroller declares nav of type navcontroller.

when run ionic serve, ionic runs webpack compile , package code. since not valid js syntax, fails.

ionic 2 based on angular 2, written in typescript. while angular 2 can used plain javascript, undocumented, , recommend using typescript when developing angular 2 applications.

when create new ionic 2 project, should use --ts flag if want project in typescript. command should be:

ionic start myionic2project --v2 --ts 

after that, copy-pasting ionic 2 tutorials should work you.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -