使用@ ngrx / store和@ ngrx / core与System.js模块加载器

时间:2017-02-10 15:10:39

标签: angular ngrx

为了在我的示例Angular 2 [2.4.0]应用程序中使用@ ngrx / store [2.2.1]和@ ngrx / core [1.2.0]进行状态管理,我按照以下步骤进行操作

  1. 已安装@ ngrx / store [2.2.1]和@ ngrx / core
  2. 添加以下导入到根模块

    import { StoreModule } from '@ngrx/store'; 
    
  3. 3在systemjs.config.js文件的包部分中添加了以下代码

     '@ngrx/core': {
              main: 'bundles/core.umd.js',
              format: 'cjs'
          },
          '@ngrx/store': {
              main: 'bundles/store.umd.js',
              format: 'cjs'
          }     
    

    当我浏览网站时,我在浏览器控制台中遇到错误

      

    无法加载资源:服务器响应状态为404(未找到)“http://localhost:62818/@ngrx/store/bundles/store.umd.js

    知道需要修改哪些内容才能解决此问题。

1 个答案:

答案 0 :(得分:6)

正如@ estus所提到的,这是一个路径问题。使用正确的路径向地图部分添加以下行解决了问题

'@ngrx/core': 'node_modules/@ngrx/core/bundles/core.umd.js',
'@ngrx/store': 'node_modules/@ngrx/store/bundles/store.umd.js',