2016-11-15 12 views
1

私はログインページを作成しなければなりませんでしたが、それを行う前に、JSONオブジェクトで簡単なHTTP取得を試みました。しかし、ページが、私はこのラインAngular2、HTTPリクエスト

<script src="node_modules/angular2/bundles/http.dev.js"></script>

のindex.htmlで書く場合arror (index):18 Error: (SystemJS) XHR error (404 Not Found) loadingを解決できることを私は読んでいくつかの記事で enter image description here

をロードしませんが、それはありません負荷しないでください。私は

<script src="node_modules/@angular/bundles/http.dev.js"></script>

を試してみましたが、何も助けません。私の輸入では、私は@angular代わりのangular2

のhier私のpackage.jsonである

{ 
 
    "name": "angular-quickstart", 
 
    "version": "1.0.0", 
 
    "scripts": { 
 
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ", 
 
    "lite": "lite-server", 
 
    "tsc": "tsc", 
 
    "tsc:w": "tsc -w" 
 
    }, 
 
    "licenses": [ 
 
    { 
 
     "type": "MIT", 
 
     "url": "https://github.com/angular/angular.io/blob/master/LICENSE" 
 
    } 
 
    ], 
 
    "dependencies": { 
 
    "@angular/common": "~2.2.0", 
 
    "@angular/compiler": "~2.2.0", 
 
    "@angular/core": "~2.2.0", 
 
    "@angular/forms": "~2.2.0", 
 
    "@angular/http": "~2.2.0", 
 
    "@angular/platform-browser": "~2.2.0", 
 
    "@angular/platform-browser-dynamic": "~2.2.0", 
 
    "@angular/router": "~3.2.0", 
 
    "@angular/upgrade": "~2.2.0", 
 
    "angular-in-memory-web-api": "~0.1.15", 
 
    "core-js": "^2.4.1", 
 
    "reflect-metadata": "^0.1.8", 
 
    "rxjs": "5.0.0-beta.12", 
 
    "systemjs": "0.19.39", 
 
    "zone.js": "^0.6.25" 
 
    }, 
 
    "devDependencies": { 
 
    "@types/core-js": "^0.9.34", 
 
    "@types/node": "^6.0.45", 
 
    "concurrently": "^3.0.0", 
 
    "lite-server": "^2.2.2", 
 
    "typescript": "^2.0.3" 
 
    } 
 
}

と私のコード https://gist.github.com/anonymous/d3b5f00ed5e9a5d3db603bf6eafb402fhttps://gist.github.com/anonymous/d6940887480a6501a539fa15f8de6b9f

を持っているあなたの助けに感謝多くを

+0

は、いくつかのより多くのコードをポストする必要があります。 –

+0

'node_modules'の下に' @ angular'がありますか? –

+0

'packages.json'を投稿できますか? 'npm install'を実行しましたか? –

答えて

0

HttpModuleをモジュールにインポートする必要があります。あなたがつもりだ

app.module.ts

import { HttpModule } from '@angular/http'; // add this line 

@NgModule({ 
    imports: [ 
     //.... 
     HttpModule //make sure you import `HttpModule` into `NgModule` 
    ], 
    // ... 
)} 
関連する問題