用Angular 2运行Ionic 2

时间:2017-04-11 01:19:20

标签: angular ionic-framework ionic2

几天前,我开始玩Ionic 2和Angular 2,但是现在当我运行“ionic start myProjectName blank --v2”时,它总是会创建一个带有v3.0.1离子框架的新项目。即使我指定“--v2”,它也会使用Ionic 3.0.1和Angular 4,但我想使用带角度2的Ionic 2,因为我认为将Ionic 3和Angular 4用于生产网络应用程序还为时尚早。< / p>

这是我的命令“$ ionic info”输出:

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

和我的package.json依赖项阻止:

 "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"
  },

[编辑] 如果这个云帮助其他人,我也会在Ionic论坛上发布这个问题。非常感谢https://forum.ionicframework.com/t/ionic-2-with-angular2/86072/2

2 个答案:

答案 0 :(得分:5)

ionic blog

根据这个,

  

使用CLI的2.x版仍需要--v2标志来使用最新版本的框架(当前为3.0.1)创建应用程序。如果您使用的是CLI版本(3.0.0-beta.5是最新版本),它不需要任何标记,并将使用最新版本的框架(3.0.1)生成应用程序。

     

因此,不再可能使用最新的v2框架(我认为是2.2.0或2.3.0)创建一个新的应用程序。它现在是1. 或3.0.0。

答案 1 :(得分:0)

您只需将package.json更改为旧版本

即可
"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.2.0",
  "ionic-native": "2.8.1",
  "ionicons": "3.0.0",
  "rxjs": "5.0.1",
  "sw-toolbox": "3.4.0",
  "zone.js": "0.7.2"

},

然后运行>_ npm install