我搜索了大约 2 个小时,我的错误在哪里。 这就是原因,我尝试在这里提出我的问题。 我有这个错误:
"angular2-cookies/core.js not found"
我已经使用 npm 正确安装了 angular2-cookie。
这是我的 ServiceCookie:
import { Injectable } from '@angular/core';
import {CookieService, CookieOptionsArgs} from 'angular2-cookie/core';
@Injectable()
export class CookiesService {
private option: CookieOptionsArgs;
constructor(private cookieService: CookieService) {
}
getCookie(key: string) {
return this.cookieService.get('cookieName');
}
setCookie(key: string, value: string) {
var expiresDate = new Date(new Date().getTime() + 3600 * 1000);
this.option.expires = expiresDate.toDateString();
// 10 ans pour le moment
this.cookieService.put(key, value, this.option.expires);
}
deleteCookie(key: string) {
this.cookieService.remove(key);
}
}
这是我的 system.config.js,我在其中声明了用于运行我的应用程序的路径文件。
/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
* Override at the last minute with global.filterSystemConfig (as plunkers do)
*/
(function (global) {
// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
'rxjs': 'js/rxjs',
'@angular': 'js/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'angular2-cookie': 'node_modules/angular2-cookies'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'boot.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { defaultExtension: 'js' },
'angular2-cookie': { main: 'core.js', defaultExtension: 'js' }
};
var packageNames = [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router-deprecated',
'@angular/router',
'@angular/testing',
'@angular/upgrade'
];
var paths = {
'node_modules': 'node_modules',
'app': 'app/',
'app/*': 'app/*'
};
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
packageNames.forEach(function (pkgName) {
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
map: map,
packages: packages,
paths: paths
}
if (global.filterSystemConfig) { global.filterSystemConfig(config); }
System.config(config);
})(this);
最佳答案
我在你的 system.config.js 中发现的一个拼写错误应该是
'angular2-cookie': 'node_modules/angular2-cookie'
而不是
'angular2-cookie': 'node_modules/angular2-cookies'
在您的 map 中{},不确定这是否能完全解决问题。
关于javascript - 在我的应用程序 angular2 aspnet core 中找不到错误 angular2-cookies/core.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37751303/