Ionic Docs don't match the template generated by the CLI


#1

when the blank template is created Ionic is imported from: 'ionic-framework/ionic’
In all the tutorials Ionic is imported from: ‘ionic/ionic’;

I am running Ionic version 2.0.0-beta.17

Another thing that happens is that in the constructor of any of the pages in the app once I put the following syntax:
constructor(app: IonicApp, platform: Platform) {}

I get the following error in the CLI:
Unexpected token (14:17)
12 | }
13 |

14 | constructor(app: IonicApp, platform: Platform) {
| ^
15 |
16 | // set up our app
17 | this.app = app;

Any ideas?


#2

I’ve been struggling with this for the whole day. I managed to override my previous revision to the newest and suddenly everything stopped working.

The fix is to add this right before constructor():

static get parameters() {
  return [[Platform]];
}

constructor(platform) {
...

That is the equivalent to:

constructor(platform: Platform) {
...

However, I am uncertain how you should work with multiple modules. But I suppose it would be:

static get parameters() {
  return [[IonicApp], [Platform]];
}

constructor(app, platform) {
...

Let me know if it worked!


#3

You are the man!
The error has gone away, I am playing around with the cordova.InAppBrowser plugin.
I added the plugin with the following line:
ionic plugin add org.apache.cordova.inappbrowser

The standard import doesn’t work:
cordova plugin add cordova-plugin-inappbrowser

shows the following error:
Error: 404 Not Found: cordova-plugin-inappbrowser

Now when I run my app with the following code in my home.html:

`export class HomePage {
static get parameters() {
return [[Platform]];
}

constructor(platform) {
this.platform = platform;
}

launch(url) {
this.platform.ready().then(() => {
try{
cordova.InAppBrowser.open(url, “_system”, “location=true”);
}catch(e){
alert(e.message);
}

});

}
}`

cordova is undefined, do you have any idea why this would happen?