我必须创建登录页面,但在此之前,我尝试了使用简单的HTTP get和JSON对象。但是该页不加载enter image description here
在一些帖子中,我读到如果我用index.html写这行代码,就可以解决arror (index):18 Error: (SystemJS) XHR error (404 Not Found) loading
<script src="node_modules/angular2/bundles/http.dev.js"></script>
,但它不加载。我试过了
<script src="node_modules/@angular/bundles/http.dev.js"></script>
但没有任何帮助。在我的导入中,我有@angular stead angular2
此处是我的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/d3b5f00ed5e9a5d3db603bf6eafb402f和https://gist.github.com/anonymous/d6940887480a6501a539fa15f8de6b9f
非常感谢你的帮助
发布于 2016-11-16 09:42:18
您需要将HttpModule导入到模块中。
app.module.ts
import { HttpModule } from '@angular/http'; // add this line
@NgModule({
imports: [
//....
HttpModule //make sure you import `HttpModule` into `NgModule`
],
// ...
)}https://stackoverflow.com/questions/40621192
复制相似问题