截至Angular 2 Alpha 54(更改日志),RxJS
不再包含在Angular 2中.
更新:原来zone.js
并且reflect-metadata
也被排除在外.
因此,我现在遇到以下错误(如Chrome开发者控制台中所示):
system.src.js:4681 GET http://localhost:3000/rxjs/Subject 404 (Not Found)F @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681 system.src.js:4681 GET http://localhost:3000/rxjs/observable/fromPromise 404 (Not Found)F @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681 localhost/:1 Uncaught (in promise) Error: XHR error (404 Not Found) loading http://localhost:3000/rxjs/Subject(…)t @ system.src.js:4681g @ system.src.js:4681(anonymous function) @ system.src.js:4681 system.src.js:4681 GET http://localhost:3000/rxjs/operator/toPromise 404 (Not Found)F @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681(anonymous function) @ system.src.js:4681 system.src.js:4681 GET http://localhost:3000/rxjs/Observable 404 (Not Found)
我已经RxJS
在我的package.json文件(^ 5.0.0-beta.0)中,它已经安装了npm
,但问题是我现在还不熟悉,SystemJS
以便让事情运行起来.这是我index.html
文件中的正文部分:
我一直在玩其他配置,但没有一个让我一路走来.我的猜测是,这是相对简单的,只是我缺乏理解或工具的使用方式阻止了我.
这是我的app.ts文件,它是app/app
SystemJS配置中引用的:
import {Component} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; import {COMMON_DIRECTIVES} from 'angular2/common'; @Component({ selector: 'app', directives: [], template: `{{greeting}}, world!` }) export class App { greeting:string = 'Hello'; } bootstrap(App, [COMMON_DIRECTIVES]);
我正在使用一个Express
使用静态映射的livereload 服务器为应用程序提供服务,这样http://localhost:3000/node_modules/rxjs/Rx.js
即使作为服务器的根目录index.html
提供所需的文件也能够获得所需的文件/src
,并且node_modules
实际上处于同一级别src
而不是在其中.
任何帮助都将一如既往地受到赞赏.
事实证明,通过将SystemJS配置更改为我的index.html
文件中的以下内容,可以轻松解决问题:
System.config({ map: { rxjs: 'node_modules/rxjs' // added this map section }, packages: { 'app': {defaultExtension: 'js'}, 'rxjs': {defaultExtension: 'js'} // and added this to packages } }); System.import('app/app');
我实际上已经尝试过,但是我没有意识到这一点,zone.js
并且reflect-metadata
也不再包含在Angular 2中,我也遇到了这个问题.
对于那些感兴趣的人,我通过在index.html中包含该文件来解决缺乏zone.js
和reflect-metadata
最容易的问题angular2-polyfills.js
:
现在我的应用程序就像使用Alpha 53一样.