Angular 4.3 Now Available
Stephen Fluin
44910

Hi Stephen. Thanks for the update. I’m working on hybrid AngularJS/Angular app and try to use this new HttpClient module on the Angular service, but without success. This is the error I get:

zone.js:654 Unhandled Promise rejection: (SystemJS) XHR error (404 Not Found) loading http://localhost:6061/app/node_modules/@angular/common/bundles/common.umd.js/http.js
 Error: XHR error (404 Not Found) loading http://localhost:6061/app/node_modules/@angular/common/bundles/common.umd.js/http.js
 at XMLHttpRequest.wrapFn [as __zone_symbol___onreadystatechange] (http://localhost:6061/app/node_modules/zone.js/dist/zone.js:1075:39)
 at ZoneDelegate.invokeTask (http://localhost:6061/app/node_modules/zone.js/dist/zone.js:424:31)
 at Zone.runTask (http://localhost:6061/app/node_modules/zone.js/dist/zone.js:191:47)
 at ZoneTask.invokeTask [as invoke] (http://localhost:6061/app/node_modules/zone.js/dist/zone.js:498:34)
 at invokeTask (http://localhost:6061/app/node_modules/zone.js/dist/zone.js:1370:14)
 at XMLHttpRequest.globalZoneAwareCallback (http://localhost:6061/app/node_modules/zone.js/dist/zone.js:1388:17)
 Error loading http://localhost:6061/app/node_modules/@angular/common/bundles/common.umd.js/http.js as “@angular/common/http” from http://localhost:6061/app/app.module.js ; Zone: <root> ; Task: Promise.then

This is my package.json piece:

"dependencies": {
"@angular/common": "^4.3.3",
"@angular/compiler": "^4.3.3",
"@angular/core": "^4.3.3",
"@angular/forms": "^4.3.3",
"@angular/platform-browser": "^4.3.3",
"@angular/platform-browser-dynamic": "^4.3.3",
"@angular/router": "^4.3.3",
"@angular/upgrade": "^4.3.3",
"@angular/http": "^4.3.3",
"angular-in-memory-web-api": "~0.3.0",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.8.4"

This is my systemjs.config.js:

(function(global) {
System.config({
paths: {
// paths serve as alias
'npm:': '/app/node_modules/'
},
// map tells the System loader where to look for things
map: {
'ng-loader': './systemjs.angular.loader.js',

// our app is within the app folder
'app': './app',

// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
'tslib': 'npm:tslib/tslib.js',

// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js',
meta: {
'*': {
authorization: true
}
// './*.js': {
// loader: './systemjs.angular.loader.js'
// }
}
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);

This is my app.module.ts:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';
import { HttpClientModule } from "@angular/common/http";
import { SessionServiceA } from "./login/session.service";
import { StorageService } from "./local-storage/storage.service";

@NgModule({
imports: [
BrowserModule,
UpgradeModule,
HttpClientModule
],
providers: [
StorageService,
SessionServiceA
]
})

export class AppModule {
constructor(private upgrade: UpgradeModule) { }
ngDoBootstrap() {
this.upgrade.bootstrap(document.body, ['caseApp']);
}
}

And this is my session.service.ts (part of it):

import { Injectable } from '@angular/core';
import { HttpClient } from "@angular/common/http";
import { StorageService } from "../local-storage/storage.service";

declare var angular: angular.IAngularStatic;
import { downgradeInjectable } from '@angular/upgrade/static';
@Injectable()
export class SessionServiceA {

...
constructor(private localStorage: StorageService, private http: HttpClient) {}

It would be huge, if you can help me… I did not find the cause for after 2 days of searching…

Thank you in advance,

Oleg

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.