Hello World
创建Form和state¶
安装ngrx所需依赖
1 | npm install @ngrx/core @ngrx/store @ngrx/effects --save |

准备工作做完了,我们开始创建第一个form和state
在libs下面建立文件夹名为:content
1. 创建名为hrmanager的module¶
1 | ng generate lib hrmanager --tags=lib:content --directory=content --routing --lazy --unit-test--runner jest --parent-module=apps/client/src/app/app.module.ts |

2. 创建Form¶
1 | ng generate component form --project=content-hrmanager --prefix=chs-hrmanager |
3. 创建state¶
1 | npx nx g ngrx content-hrmanager --module=libs/content/hrmanager/src/lib/content-hrmanager.module.ts |
4. 修改文件¶
1 2 3 4 5 6 7 8 9 10 | // 找到下面三个文件 1. content-hrmanager.module.ts 2. content-hrmanager.selectors.ts 3. content-hrmanager.reducer.ts // 变更前 CONTENTHRMANAGER_FEATURE_KEY // 变更后 CONTENT_HRMANAGER_FEATURE_KEY |
5. 将上记创建的FormComponent导出¶

6. app.module.ts中导入hrmanager¶

7. 在app.component.html中引入hrmanager¶
清空app.component.html之后,导入hrmanager
1 | <chs-hrmanager-form></chs-hrmanager-form> |
8. 在form.component.html中写入 Hello World!¶

至此,Hello World准备工作做完了,运行程序
