首页 > 解决方案 > 是否有一些示例可以在一个命令中在 Angular 7 上创建 ngrx/Store

问题描述

我正在创建新的 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

标签: angularcommand-line-interfacestorengrx

解决方案


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

ng add @ngrx/store

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


推荐阅读