【问题标题】:NGXS: How to get the RouteHandler to work?NGXS:如何让 RouteHandler 工作?
【发布时间】:2020-02-11 22:23:07
【问题描述】:

根据此处找到的文档创建 ngxs RouteHandler 时:

https://www.ngxs.io/advanced/action-handlers

添加时出现 NullInjectorError:

providers: [
    {
      provide: APP_INITIALIZER,
      useFactory: noop,
      deps: [RouteHandler],
      multi: true
    }
  ]

有没有人使用这个记录在案的 RouteHandler 从 ngxs 操作成功地调度路由?

【问题讨论】:

    标签: ngxs


    【解决方案1】:

    这个让我有点难过。 我发现,至少在我的情况下,文档没有提到您需要在“服务”中设置 { providedIn: 'root' } - 可以这么说。

    @Injectable({ providedIn: 'root' });
    

    其他一切都与文档中解释的几乎相同。 我还(很快)做了一个stackblitz,它应该让你对应该如何设置有一个大致的了解。 https://stackblitz.com/github/baxelson12/ngxs-route-handlers

    【讨论】:

      猜你喜欢
      • 2018-11-16
      • 2018-10-30
      • 2011-05-04
      • 2011-04-07
      • 2011-07-27
      • 2011-03-08
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多