无法加载资源 angular2-cookie
Failed to load resource angular2-cookie
我正在尝试使用 visual studio 在 angular-2 的快速启动中添加 'angular2-cookie'。
正在关注 https://www.npmjs.com/package/angular2-cookie
到目前为止,我已经进行了以下更改。
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'));
应用程序构建正常,但最终加载资源失败:服务器响应状态为 404(未找到)
错误:(SystemJS) XHR 错误(404 未找到)加载 http://localhost:56249/angular2-cookie/services/cookies.service(…)
我错过了什么?
完整代码
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'));
}
}
相同的代码今天可以使用。似乎重建、删除浏览器缓存有帮助。
我正在尝试使用 visual studio 在 angular-2 的快速启动中添加 'angular2-cookie'。
正在关注 https://www.npmjs.com/package/angular2-cookie
到目前为止,我已经进行了以下更改。
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'));
应用程序构建正常,但最终加载资源失败:服务器响应状态为 404(未找到)
错误:(SystemJS) XHR 错误(404 未找到)加载 http://localhost:56249/angular2-cookie/services/cookies.service(…)
我错过了什么?
完整代码
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'));
}
}
相同的代码今天可以使用。似乎重建、删除浏览器缓存有帮助。