Create a Feature Module
- What is a Feature Module?
-
A Feature Module is a modular unit of functionality that encapsulates a specific feature or set of related features within an UI Application. It is designed to promote code reusability, maintainability, and separation of concerns by grouping related components, services, and state management logic together.
In Angular, feature modules are NgModules for the purpose of organizing code.
|
The Feature Module created with the OneCX App Generator is only the base of a functional module. |
Generate a Feature Module
The current working directory must be the root of an existing OneCX UI Application.
nx generate <namespace>/nx-plugin:feature <feature>
with:
| <namespace> |
The base namespace of the project where the application is part of. |
| <feature> |
The name of the feature module to be created. |
The generator will create a new feature module with the specified name and set up the necessary structure and configurations.
Next steps may create components, services, and state management logic within the feature module as needed, e.g. create a search component.
Example
Create a feature module book inside the application named bookstore to manage book data. Execute the following command with the bookstore application as current working directory.
nx generate @onecx/nx-plugin:feature book
This command will generate a new feature module named book with the necessary structure and configurations.