错误angular2-cookies / core.js在我的app angular2 aspnet核心中找不到

时间:2016-06-10 14:54:00

标签: javascript node.js angular cookies systemjs

我在2小时左右搜索我的错误。 这就是原因,我试着在这里问我的问题。 我有这个错误:

  

"找不到angular2-cookies / core.js"

我已经使用npm正确安装了angular2-cookie。

这是我的ServiceCookies:

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);

1 个答案:

答案 0 :(得分:1)

我在你的system.config.js中发现了一个错误,应该是

'angular2-cookie': 'node_modules/angular2-cookie'

而不是

'angular2-cookie': 'node_modules/angular2-cookies'

在您的地图{}中,不确定是否会完全修复它。