-
Notifications
You must be signed in to change notification settings - Fork 8
How to's
Benjamin edited this page Dec 3, 2021
·
2 revisions
Page under construction
Suppose you want to create a new model entity and include functionality to edit its data under the management section of the app. You'd have to follow these steps:
- Create the model class in
src/app/models/entities
- Add an injection token for api client services to the file
src/app/api/api-service-injection-tokens.ts
- For each API module; both
src/app/api/http
andsrc/app/api/local-memory
, do:- In the corresponding
data/
subdirectory, create an implementation ofITransactionalEntityDataApiService<T>
for your new model. However, if you just need to read data, you can implementIEntityDataApiService<T>
instead. - In the module, add a provider for the new injection token, using this service implementation.
- In the corresponding
- Create a reactive form component for your model in
src/app/shared/components/
, there's examples for every managed entity.- Remember to declare it in and export it from the module, like the rest of entity form components.
- Add a component/service couple, like the existing ones in
src/management/routes/
. All of these are descendants ofDataManagerComponentDirective<T>
andDataManagerServiceDirective<T>
). Make sure you use the correct injection token. - And finally, include the route data to forward to that component inside the array declared in
src/management/management-routing.module.ts
. The sidenav will show it up. However, remember that the API dictates which data contexts one is permitted to , calling/access/{context}
.
You can let the entity form component do all the validation and execute business rules if any are required.