I am trying to add 'angular2-cookie' in the quick start of angular-2 using visual studio.
following https://www.npmjs.com/package/angular2-cookie
I have made the following changes so far.
npm install angular2-cookie --save
System.config
map:
// other libraries
'angular2-cookie': 'npm:angular2-cookie'
packages:'angular2-cookie': {
main: './core.js',
defaultExtension: 'js'
}
app.component.ts
import { CookieService } from 'angular2-cookie/services/cookies.service';
providers: [CookieService]
constructor(private _cookieService: CookieService) {
_cookieService.put("test.com", "testCookie");
console.log(_cookieService.get('test.com'));
The app builds fine, but ends up with Failed to load resource: the server responded with a status of 404 (Not Found)
Error: (SystemJS) XHR error (404 Not Found) loading http ://localhost:56249/angular2-cookie/services/cookies.service(…)
What am I missing?
Complete Code
system.config:
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// 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/http': 'npm:@angular/http/bundles/http.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',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
'angular2-cookie': 'npm:angular2-cookie'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
},
'angular2-cookie': {
main: './core.js',
defaultExtension: 'js'
}
} });
app.component.ts
import { Component } from '@angular/core';
import { CookieService } from 'angular2-cookie/services/cookies.service';
@Component({
selector: 'my-app',
template: '<h1>Quickstart for angular</h1><div> Hello there!</div>',
providers: [CookieService]
})
export class AppComponent {
constructor(private _cookieService: CookieService) {
_cookieService.put("test.com", "testCookie");
console.log(_cookieService.get('test.com'));
}
}