[英]Angular2 [typescript] error while injection Http to service
Sources with problem: https://github.com/clicman/angular2-app/ 有问题的来源: https : //github.com/clicman/angular2-app/
I`ve tried to inject Http to service and it leads with error: 我已经尝试将Http注入服务,并导致错误:
http:1 Uncaught SyntaxError: Unexpected token <__exec @ system.src.js:1374entry.execute @
system.src.js:3300linkDynamicModule @ system.src.js:2921link @ system.src.js:2764execute @
system.src.js:3096doDynamicExecute @ system.src.js:715link @ system.src.js:908doLink @
system.src.js:569updateLinkSetOnLoad @ system.src.js:617(anonymous function) @ system.src.js:430run @
angular2-polyfills.js:138zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$$internal$$tryCatch @
angular2-polyfills.js:1511lib$es6$promise$$internal$$invokeCallback @
angular2-polyfills.js:1523lib$es6$promise$$internal$$publish @ angular2-polyfills.js:1494(anonymous
function) @ angular2-polyfills.js:243run @ angular2-polyfills.js:138zoneBoundFn @
angular2-polyfills.js:111lib$es6$promise$asap$$flush @ angular2-polyfills.js:1305
angular2-polyfills.js:138 Uncaught SyntaxError: Unexpected token <
Evaluating http://localhost:3000/angular2/src/http/http
Error loading http://localhost:3000/scripts/boot.js
Service code: 服务代码:
import {Injectable} from 'angular2/core'
import {Http} from 'angular2/src/http/http';
@Injectable()
export class CommentsService {
constructor(private _http: Http) { }
public getComments(): any[] {
return [];
}
}
What I do wrong? 我做错了什么?
您应该将angular2/bundles/http.dev.js
到index.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.