【问题标题】:@ngrx/store-devtools: instrumentStore() returns an array of objects instead of providers@ngrx/store-devtools:instrumentStore() 返回一个对象数组而不是提供者
【发布时间】:2016-07-10 17:32:51
【问题描述】:

我正在使用以下种子开发 Angular 2 项目:angular2-webpack-starter,并且我也在使用 @ngrx/store 和 @ngrx/store-devtools

在引导期间,应用程序抛出错误:

zone.js:260 - Uncaught Invalid provider - only instances of Provider and Type are allowed, got: [object Object]

这是我使用种子设置 @ngrx 的方法:

将包添加到vendor.browser.ts

// ngrx
import '@ngrx/core';
import '@ngrx/store';
import 'ngrx-store-router';

if ('production' === ENV) {
  // Production


} else {
  // Development
  require('angular2-hmr');
  require('@ngrx/store-devtools');
  require('@ngrx/store-log-monitor');

}

为 Angular 2 添加提供程序 (browser-providers.ts)

// @ngrx/store
import { provideStore } from '@ngrx/store';
// @ngrx/devtools
import { instrumentStore } from '@ngrx/store-devtools';
import { useLogMonitor } from '@ngrx/store-log-monitor';
// link angular's router with ngrx/sotre
import { routerMiddleware } from 'ngrx-store-router';
// custom data for ngrx
import { REDUCERS, initialState } from '../app/shared/redux';

export const APPLICATION_PROVIDERS = [
  // awesome redux implementation for angular
  provideStore(REDUCERS, initialState),
  instrumentStore({
    monitor: useLogMonitor({
      visible: true,
      position: 'right'
    })
  }),

  // link angular's router with ngrx/sotre
  routerMiddleware,

  //...
];

将监视器添加到我的应用模板

<ngrx-store-log-monitor toggleCommand="ctrl-h" positionCommand="ctrl-m"></ngrx-store-log-monitor>.


简单。

但是当我 console.log instrumentStore() 返回时,我得到一个对象数组。但是 Angular 需要和提供者的数组。

这是我的包的版本:

  • Angular2:rc3
  • @ngrx/核心:1.0.1
  • @ngrx/store: 1.5.0
  • @ngrx/store-devtools: 2.0.0-beta1
  • @ngrx/store-log-monitor: 2.0.0-beta1

如果有问题,我会在 Github 上报告。但我不确定是否正确设置。

谢谢。

【问题讨论】:

    标签: typescript angular webpack ngrx


    【解决方案1】:

    问题很简单。 我已将 @ngrx/store 升级到版本 2 (2.0.1) 并且可以正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-06
      • 1970-01-01
      • 2016-05-03
      • 2017-05-29
      • 1970-01-01
      • 2017-06-08
      • 2019-05-18
      相关资源
      最近更新 更多