Angular最新beta.0错误:错误:(15,25)TS2304:找不到姓名' Http'。 试过像
这样的差异import {Http} from 'angular2/core';
import {Http} from 'angular2/core';
import {Http} from 'angular2/http.dev';
import {Http} from 'angular2/bundles/http';
一切都没有运气:(
这是我的组件:
///<reference path="../../typings/es6-promise/es6-promise.d.ts"/>
///<reference path="../../typings/zone.js/zone.js.d.ts"/>
import {Component} from 'angular2/core';
import {Injectable} from 'angular2/core';
import {Inject} from 'angular2/core';
import {HTTP_PROVIDERS, Http} from 'angular2/http';
@Component({
providers: [HTTP_PROVIDERS]
})
@Injectable()
export class MyService {
private _val:number;
constructor(@Inject(Http) http:Http) {
this._val = Math.random();
}
public showAlert() {
alert(`here is an alert ${this._val}`);
}
}
答案 0 :(得分:0)
从ng2 beta开始需要将我的system.js更改为
<script>
System.config({
defaultJSExtensions: true,
transpiler: 'typescript',
packages: {
'component': {defaultExtension: 'ts'}
},
typescriptOptions: {emitDecoratorMetadata: true}
});
System.import('./component/App.ts')
希望它可以帮助某人...