Angular2 beta - bootstrapping HTTP_PROVIDERS - “Unexpected Token <”

后端 未结 2 1024
日久生厌
日久生厌 2020-12-10 10:26

Starting with the 5 minute quick start I\'ve been playing around the angular2 beta and have run across a problem that has me stumped.

Here is a dumbed down version t

相关标签:
2条回答
  • 2020-12-10 11:04

    If you're using npm, include a script tag with the http reference to your local installation:

    <script src="node_modules/angular2/bundles/http.dev.js"></script>
    
    0 讨论(0)
  • 2020-12-10 11:22

    This error occurs when you try to import something that is not being included in your HTML when using SystemJS. Module bundlers like Webpack handle all that for you.

    For your case you have to add the Http bundle that's a separated bundle, for example

    <script src="https://code.angularjs.org/2.0.0-beta.0/http.dev.js"></script>
    

    You'll see this same error when trying to use the router and you forgot to add the router bundle.

    Check the difference between these two configurations from @pkozlowski-opensource's repos

    • Using SystemJS : For this case he would've to add http bundle, or router bundle if he wanted to use them.
    • Using Webpack : In this case Webpack bundles everything in that bundle.js file for you.

    Glad it helped.

    0 讨论(0)
提交回复
热议问题