我遇到了Angular 2 + Typescript的問題,每當我嘗試吞噬它時顯示出相同的錯誤,我嘗試了一切,包括將<引用>標記在文件中。該怎麼辦?Angular 2:無法找到模塊'angular2/core'
(7,26): error TS2307: Cannot find module 'rxjs/Rx'./Users/macbook/workspace/rss/src/app/services/rootscope.ts (8,46): error TS2307: Cannot find module 'angular2/core'./Users/macbook/workspace/rss/src/app/services/rootscope.ts (17,48): error TS2304: Cannot find name 'Observer'./Users/macbook/workspace/rss/src/app/services/api.ts (6,26): error TS2307: Cannot find module 'angular2/core'./Users/macbook/workspace/rss/src/app/services/api.ts (7,27): error TS2307: Cannot find module 'angular2/http'./Users/macbook/workspace/rss/src/app/services/api.ts (15,13): error TS2339: Property 'http' does not exist on type 'API'./Users/macbook/workspace/rss/src/app/services/api.ts (19,20): error TS2339: Property 'http' does not exist on type 'API'./Users/macbook/workspace/rss/src/app/services/api.ts (23,20): error TS2339: Property 'http' does not exist on type 'API'../src/app/app.ts (6,25): error TS2307: Cannot find module 'angular2/platform/browser'../src/app/app.ts (7,25): error TS2307: Cannot find module 'angular2/core'../src/app/app.ts (8,47): error TS2307: Cannot find module 'angular2/http'.
rootscope.ts
/// <reference path="../../../node_modules/reflect-metadata/reflect- metadata.d.ts" />
/// <reference path="../../../node_modules/angular2/typings/browser.d.ts" />
/// <reference path="../../../node_modules/angular2/core.d.ts" />
/// <reference path="../../../node_modules/angular2/http.d.ts" />
/// <reference path="../../../node_modules/rxjs/Rx.d.ts" />
import {Observable} from "rxjs/Rx";
import {Injectable,EventEmitter,Output} from "angular2/core";
@Injectable()
export class ROOT_SCOPE {
data: any;
dataChange: Observable<any>;
@Output dataChangeObserver: EventEmitter=new EventEmitter();
constructor() {
this.dataChange = new Observable((observer:Observer) => {
this.dataChangeObserver = observer;
});
}
set(data:any) {
this.data = data;
this.dataChangeObserver.next(this.data);
}
}
你使用的是什麼Angular2版本?對於=> RC.x,您需要'@angular/...'而不是'angular2/...' –
您正在處理哪個版本的angular2? – micronyks
這是2.0.0-beta.0 –