I am trying to write a very very simple app in angular 2 I need to read JSON file and therefore need angular2/http
Applied npm init
to build the packages.json
file:
{
"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 (…)
from angula2.polyfills. Not sure how to proceed. The auth0 demo here shows no need to explicitly mention angular2/http in the dependencies.
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
?
Please look into Angular CLI way of working with Angular 2 apps, it gives well structured way of development.
Angular 2 modules are loaded using system.js as in quickstart you mentioned or if you CLI.
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 .
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.