错误从ng2.0.0-beta.0移动到ng2.0.0-beta.7

时间:2016-03-05 16:57:53

标签: angular

我有一个apache cordova typescript项目,配置了ng2.0.0-beta.0包并成功启动,请参阅下面的package.json和javascript控制台输出。

我试图转移到该项目中当前的ng2.0.0-beta.7软件包,以查看它是否解决了一个意外问题,我遇到的情况是,当模板引用的类成员变量发生更改时视图不会更新,详细信息请参阅“ cordova app angular 2 member variable update not updating template reference to it”。

当我切换到ng2.0.0-beta.7软件包时,一切都很好,但是ng2没有成功启动,请参阅下面的package.json和javascript控制台输出。

我对acu6withng27主题分支https://github.com/myusrn/acu6withng2https://github.com/myusrn/acu6withng2/tree/acu6withng27和ng2.0.0-beta.7案例的主分支中的ng2.0.0-beta.0案例进行了重新编译。

任何人都会看到ng2.0.0-beta.7的运行时错误,如果是这样,是因为我忽视了一些步骤,或者有一个已知的修复程序吗?

ng2.0.0-beta.7 package.json

"dependencies": {
    "angular2": "2.0.0-beta.7",
    "es6-promise": "3.0.2",
    "es6-shim": "0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "systemjs": "0.19.9",
    "zone.js": "0.5.10"
  },

ng2.0.0-beta.7运行时javascript控制台输出错误

Uncaught TypeError: Cannot redefine property: onreadystatechange
angular2-polyfills.js (1569,25)
DEPRECATION WARNING: 'enqueueTask' is no longer supported and will be removed in next major release. Use addTask/addRepeatingTask/addMicroTask
angular2-polyfills.js (1152,18)
DEPRECATION WARNING: 'dequeueTask' is no longer supported and will be removed in next major release. Use removeTask/removeRepeatingTask/removeMicroTask
angular2-polyfills.js (1152,18)
reflect-metadata shim is required when using class decorators
    Error loading http://localhost:4400/app/main.js
angular2-polyfills.js (468,17)

ng2.0.0-beta.0 package.json

"dependencies": {
    "angular2": "2.0.0-beta.0",
    "es6-promise": "3.0.2",
    "es6-shim": "0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "systemjs": "0.19.9",
    "zone.js": "0.5.10"
  },

ng2.0.0-beta.0运行时javascript控制台输出

Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
angular2.dev.js (351,13)

ng2.0.0-beta.0 / .7 index.html

<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>
<!--<script src="scripts/appbundle.js"></script>-->
<script src="scripts/index.js"></script>

<!-- 1. Load libraries needed for ng2 -->
<script src="node_modules/es6-shim/es6-shim.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>

1 个答案:

答案 0 :(得分:2)

我找到了一个解决方案,只需将以下内容添加到index.html脚本标记列表中,并使用新的ng 2.0.0-beta.8包。

<script src="node_modules/reflect-metadata/Reflect.js"></script>

由于此详细信息不是当前https://angular.io/guide/quickstart的一部分,因此我不确定我的hello world项目环境是否存在问题,或者需要将详细信息添加到快速入门说明中进入index.html脚本标签。