【问题标题】:Is there some example to create ngrx/Store on Angular 7 in one command是否有一些示例可以在一个命令中在 Angular 7 上创建 ngrx/Store
【发布时间】:2019-11-13 06:39:22
【问题描述】:

我正在创建新的 Web 仪表板并使用 ngrx/store 在 Angular 7 中加载和数据。大约第三次我正在为不同的商店界面创建和生成文件,并且它似乎不会在这里停止。所以我想知道是否有一些 cli 包可以在一个命令行中为模块创建存储。

我每次都最好使用 cli 来创建动作、效果、减速器、状态。我尝试了一些来自 cli 的解决方案,但它只创建了 reducer 和 index.ts。

npm install @ngrx/schematics --save-dev
npm install @ngrx/{store,effects,entity,store-devtools} --save
ng config cli.defaultCollection @ngrx/schematics
ng generate @ngrx/schematics:store State --root --module some-app.module.ts -d

【问题讨论】:

    标签: angular command-line-interface store ngrx


    【解决方案1】:

    可能是ng update 命令,例如https://ngrx.io/guide/store/install#installing-with-ng-add

    ng add @ngrx/store
    

    这将安装 @ngrx/store 并做一个最小的脚手架来帮助你开始。

    【讨论】:

    • 谢谢,。但我没有安装它的问题,我已经在使用 store 并且我创建了 store 和 ngrx。问题是我创建商店捆绑文件(效果、商店、动作、减速器)太多次。我想知道是否有一些带有参数的 CLI,例如 ng generate @ngrx/schematics:store MyStore --root --module some-app.module.ts -d --action --effects --state --selectors 或类似的东西
    • 我认为在一行中没有这样的命令可以生成所有这些动作、效果等。您需要使用单独的命令。请参阅ngrx.io/guide/schematics 文档。
    猜你喜欢
    • 2017-06-03
    • 2010-11-29
    • 2011-12-18
    • 1970-01-01
    • 1970-01-01
    • 2011-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多