2

Sources with problem: https://github.com/clicman/angular2-app/

I`ve tried to inject Http to service and it leads with error:

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?

1 Answer 1

5

You should add the angular2/bundles/http.dev.js to the index.html

Sign up to request clarification or add additional context in comments.

3 Comments

Great! It works now. Thank you. Is some tools to automate needed scripts to index.html?
No, not really. When you start using 'routing' you have to add the routing module from angular. But all the components you write are automatically loaded by systemjs
Just a note to others. http.dev.js needs to be added AFTER system.src.js

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.