Wie lade ich RxJS (und zone.js / reflect-metadata) mit Angular 2 (Beta und neuer)?
As von Angular 2 Alpha 54 Änderungsprotokol),RxJS
ist in Angular 2 nicht mehr enthalten.
Update: Stellt sich heraus, dasszone.js
undreflect-metadata
sind ebenfalls ausgeschlossen.
Als Ergebnis erhalte ich jetzt die folgenden Fehlermeldungen (in der Chrome-Dev-Konsole):
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)
Ich habeRxJS
in meiner package.json-Datei (^ 5.0.0-beta.0), und es wurde mit @ installienpm
, aber das Problem ist, ich bin einfach nicht vertraut genug mitSystemJS
zu diesem Zeitpunkt, um die Dinge zum Laufen zu bringen. Hier ist der Body-Abschnitt von meinemindex.html
Datei
<body>
<app></app> <!-- my main Angular2 tag, which is defined in app/app as referenced below -->
<script src="../node_modules/systemjs/dist/system.js"></script>
<script src="../node_modules/typescript/lib/typescript.js"></script>
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="../node_modules/angular2/bundles/http.dev.js"></script>
<script>
System.config({
packages: {'app': {defaultExtension: 'js'}}
});
System.import('./app/app');
</script>
<script src="http://localhost:35729/livereload.js"></script>
</body>
Ich habe mit anderen Konfigurationen rumgespielt, aber keine hat mich den ganzen Weg dahin gebracht. Ich vermute, dass dies relativ einfach ist. Es ist nur mein Unverständnis oder die Art und Weise, wie die Werkzeuge verwendet werden, die mich aufhält.
Hier ist meine app.ts-Datei, die das @ iapp/app
wird in der SystemJS-Konfiguration angegeben:
import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {COMMON_DIRECTIVES} from 'angular2/common';
@Component({
selector: 'app',
directives: [],
template: `<div>{{greeting}}, world!</div>`
})
export class App {
greeting:string = 'Hello';
}
bootstrap(App, [COMMON_DIRECTIVES]);
Ich bediene die App mit einer LeberladungExpress
-Server, der statische Zuordnungen verwendet, sodass Aufrufe wiehttp://localhost:3000/node_modules/rxjs/Rx.js
sind in der Lage, die benötigte Datei zu erhalten, obwohlindex.html
wird von @ bedie/src
als Root des Servers undnode_modules
ist eigentlich auf dem gleichen Niveau wiesrc
und nicht drin.
Jede Hilfe wäre, wie immer, dankbar.