This is an example to show how state management can be done using ngrx
in angular project.
In order to get started please execute below script on your local box.
git clone https://github.com/roopkt/product-management.git
cd product-management
npm i
npm start
In order to start example app please run below cli command and navigate to http://localhost:4322/
url.
npm start
npm run example:test
Suppose I want to create products module in eample app. Here is the cli command:
ng g m products
suppose I have a feature module called as products
and now I want to create an add product container component
inside it. Here is the cli command for that:
ng g c products/containers/add-product-container
ng g c products\components\product-image
Lib is the module where we will create our components and share it with example-app
npm run lib:test:sr
npm run lib:test
lib:test:chrome
ng g m items --app=lib
ng g c containers\product-image-container --app=lib
This module is a feature library therefore
import in appmodule
import { FeatureModuleModule } from '@co-branding/product-management';
@NgModule({
imports: [
...
FeatureModuleModule.forFeature({ baseUrl: 'someurl' }),
],
...
})
export class AppModule { }
import { Component, OnInit } from '@angular/core';
@Component({
template: `
<pm-add-product-container></pm-add-product-container>
`,
})
export class HomeContainerComponent implements OnInit {
constructor() {}
ngOnInit() {}
}