Ionic 2 with Angular2

[Sorry for my English]

A few days ago I start playing with Ionic 2 and Angular 2, but now when I run “ionic start myProjectName blank --v2” it always creates a new project with the v3.0.1 ionic framework. Even if I specify “–v2” it uses Ionic 3.0.1 and Angular 4 but I want to use Ionic 2 with angular 2 because I think it is too soon to use Ionic 3 and Angular 4 for production web apps.

Here is my command “$ ionic info” output:

Your system information:

Cordova CLI: 6.5.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.10.0
Xcode version: Not installed

and my package.json dependencies block:

“dependencies”: {
"@angular/common": “4.0.0”,
"@angular/compiler": “4.0.0”,
"@angular/compiler-cli": “4.0.0”,
"@angular/core": “4.0.0”,
"@angular/forms": “4.0.0”,
"@angular/http": “4.0.0”,
"@angular/platform-browser": “4.0.0”,
"@angular/platform-browser-dynamic": “4.0.0”,
"@ionic-native/core": “3.4.2”,
"@ionic-native/splash-screen": “3.4.2”,
"@ionic-native/status-bar": “3.4.2”,
"@ionic/storage": “2.0.1”,
“ionic-angular”: “3.0.1”,
“ionicons”: “3.0.0”,
“rxjs”: “5.1.1”,
“sw-toolbox”: “3.4.0”,
“zone.js”: “^0.8.4”
},

Is there a way I can “downgrade” the Ionic framework version of v2.3.0 that use Angular 2?

Thanks you so much guys.

Update your package.json to match the following dependencies, remove the existing node_modules directory, and then run npm install:

  "dependencies": {
    "@angular/common": "2.4.8",
    "@angular/compiler": "2.4.8",
    "@angular/compiler-cli": "2.4.8",
    "@angular/core": "2.4.8",
    "@angular/forms": "2.4.8",
    "@angular/http": "2.4.8",
    "@angular/platform-browser": "2.4.8",
    "@angular/platform-browser-dynamic": "2.4.8",
    "@angular/platform-server": "2.4.8",
    "@ionic/storage": "2.0.0",
    "ionic-angular": "2.3.0",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "rxjs": "5.0.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.7.2"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.1.4",
    "typescript": "2.0.9"
  }

Upgrading to Ionic Native 3.x will result in a smaller bundle size. With Ionic Native 3, native functionality was moved from static methods to using Angular injectables.

Blog Post: http://blog.ionic.io/ionic-native-3-x/
Example Upgrade Commit: https://github.com/driftyco/ionic-conference-app/commit/62088

1 Like

I would also like to say that Angular 4 makes your app bundles much smaller, and I would recommend using it. I’m not a big fan of the lazy page loading of Ionic 3, but it is easily avoided.

1 Like

Angular 4 is backward compatible to Angular 2.

1 Like

Thank you. I tried this solution and the CLI is now at 2.3.0 as I wanted.

Thanks for your answers, I realized that the CLI force you to use the latest version of the Framework and I am trying to battle against it. Also I learn that the > --v2 flag stand for Ionic Framework v2.x.x but I was wrong, it stand for the latest/current version that has been released (ref: https://blog.ionic.io/ionic-3-0-has-arrived/).

I’ll build something with the new ionic (v3.0.1) version and Angular 4.

If this can help someone, I also post the question in Stack Overflow community:

Thank you guys for sharing your experiences!

Yes Ionic developers have said on Github they force Ionic 3 as default, even if you use --v2 as parameter. Something I think quite awkward personnally (as Ionic 3 is clearly in beta stage).

1 Like

the --v2 flag is a bad name really, but the general idea is that it pulls the latest released version and not a V1 project.

3.0.1 is the latest stable release so that is what we default to.

1 Like