[英]Loading redux in angular 2, systemjs
I m studying angular 2 and I wanted to use redux with it. 我正在研究angular 2,并且想与它一起使用redux。
Actually, I've created my project using angular-cli on rc2 release. 实际上,我已经在rc2版本上使用angular-cli创建了我的项目。
I m having this systemjs configuration : 我有这个systemjs配置:
/***********************************************************************************************
* User Configuration.
**********************************************************************************************/
/** Map relative paths to URLs. */
const map: any = {
};
/** User packages configuration. */
const packages: any = {
};
////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
* Everything underneath this line is managed by the CLI.
**********************************************************************************************/
const barrels: string[] = [
// Angular specific barrels.
'@angular/core',
'@angular/common',
'@angular/compiler',
'@angular/http',
'@angular/router',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
// Thirdparty barrels.
// App specific barrels.
'app',
'app/shared'
/** @cli-barrel */
];
const cliSystemConfigPackages: any = {};
barrels.forEach((barrelName: string) => {
cliSystemConfigPackages[barrelName] = { main: 'index' };
});
/** Type declaration for ambient System. */
declare var System: any;
// Apply the CLI SystemJS configuration.
System.config({
map: {
'@angular': 'vendor/@angular',
'rxjs': 'vendor/rxjs',
'main': 'main.js',
'redux': 'vendor/redux/dist/redux.js',
},
packages: cliSystemConfigPackages
});
// Apply the user's configuration.
System.config({ map, packages });
And in my angular-cli.build.js : 在我的angular-cli.build.js中:
/* global require, module */
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
'redux/dist/redux.js',
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'zone.js/dist/**/*.+(js|js.map)',
'es6-shim/es6-shim.js',
'reflect-metadata/**/*.+(js|js.map)',
'rxjs/**/*.+(js|js.map)',
'@angular/**/*.+(js|js.map)'
]
});
};
The fact is that I m having this error in the web console : 事实是我在Web控制台中遇到此错误:
What should I change to make redux available inside of my angular 2 app ? 我应该怎么做才能使Redux在我的angular 2应用程序中可用? I m pretty sure this is a systemjs error and I don't know how to process...
我很确定这是一个systemjs错误,我不知道该如何处理...
Thanks for your help 谢谢你的帮助
此注释中的配置为我解决了Redux问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.