angular module and components | create angular module | create angular components |okay java
Buy me a coffee - https://www.buymeacoffee.com/okayjava
what is angular module ?
Angular refers to a place where you can group the components, directives, pipes, and services.
command to create a new module
ng g m yourmodulename
ng generate module yourmodulename
Each module will have its own yourmodulename.module.ts file
what is angular component?
Components are the main building block for Angular applications
Each component will have 4 files 1. HTML, 2. TS, 3. CSS 4. Test case file
Command to create component
cd yourmodulename
ng g c yourcomponentname
ng generate component yourcomponentname
#Steps to use new module and component
1. Goto yourmodulename.module.ts file
Export yourcomponentname ( new component )
exports : [ yourcomponentname ]
2. Goto app.module.ts (root module)
Add yourmodulename ( new module ) in imports section
imports :[ yourmodulename ]
3. Copy the value of selector from yourcomponentname .module.ts file
and add in app.component.html file
yourcomponent-selector-value
Enjoy :)