Components
Components are the combination of template view (html and css) and business logic (TypeScript). Each component is responsible of one section of the screen.
For example, if a component is a loginComponent, it will be responsible of displaying login page template and logic for login page.
Benefits
- Easy to reuse the style and logic.
- Split each part of the screen
- Easy to integrate
- Easy to update and add components
Code Practice of Creating Components
First, we will make new project named componentDemo.
1
$ ng new componentDemo
Now go inside the app directory and create new component named my-first-component
1
2
$ cd ./src/app
$ ng g c my-first-component