[英]configure angular2 http in packages.json
I am trying to write a very very simple app in angular 2 I need to read JSON file and therefore need angular2/http
我正在尝试在angular 2中编写一个非常非常简单的应用程序,我需要读取JSON文件,因此需要
angular2/http
Applied npm init
to build the packages.json
file: 应用
npm init
来构建packages.json
文件:
{
"name": "front-end",
"version": "1.0.0",
"description": " blah blah",
"main": "gulpfile.js",
"dependencies": {
"connect": "^3.4.1",
"del": "^1.2.1",
"angular2": "2.0.0-beta.16",
"gulp": "^3.9.1",
"gulp-typescript": "^2.13.0",
"open": "^0.0.5",
"reflect-metadata": "^0.1.2",
"serve-static": "^1.10.2",
"systemjs": "^0.19.27",
"zone.js": "^0.6.12",
"rxjs": "5.0.0-beta.2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "www.hello.com"
},
"author": "kpmg-dna-fs-de",
"license": "ISC"
}
I get the following: 我得到以下内容:
Error: Error: XHR error (404 Not Found) loading http://localhost:9000/angular2/http.js (…) 错误:错误:XHR错误(找不到404)正在加载http:// localhost:9000 / angular2 / http.js (…)
from angula2.polyfills. 来自angula2.polyfills。 Not sure how to proceed.
不知道如何进行。 The auth0 demo here shows no need to explicitly mention angular2/http in the dependencies.
此处的auth0演示表明无需在依赖项中明确提及angular2 / http。
What is the difference with the use of: 使用以下有什么区别:
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.1",
as in here I mean: I get the version number, but why "angular2": "2.0.0-rc.1"
not work with npm install
? 就像在这里我的意思是:我得到了版本号,但是为什么
"angular2": "2.0.0-rc.1"
在npm install
不起作用?
Please look into Angular CLI way of working with Angular 2 apps, it gives well structured way of development. 请研究使用Angular 2应用程序的Angular CLI方式,它提供了结构良好的开发方式。
Angular 2 modules are loaded using system.js as in quickstart you mentioned or if you CLI. 如您提到的快速入门或CLI中所述,使用system.js加载Angular 2模块。
How ever from your questions i would draw below points. 从您的问题来看,我将如何总结以下几点。
Want to build Angular 2 app -- either follow quickstart link or better use Angular CLI . 想要构建Angular 2应用程序-要么跟随快速入门链接,要么更好地使用Angular CLI 。
Want to use HTTP way to access data -- use angular2-in-memory-web-api, using this you can load data from JSON file & pass this data to UI using Angular 2 HTTP concept. 想要使用HTTP方式访问数据-使用angular2-in-memory-web-api,使用它可以从JSON文件加载数据,并使用Angular 2 HTTP概念将此数据传递给UI。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.