Creating a Component
Explore how to create Angular components with the Angular CLI to generate necessary files quickly. Understand component selectors, template usage, and how to reuse components effectively to build manageable and scalable applications.
We'll cover the following...
Components can be generated with the Angular CLI. While not mandatory, creating a component using the CLI can save a lot of time. It will save us the trouble of having to create the necessary files and configure the component. We can create a component with the ng generate component <name> command. We’ll use this command to create a Post component.
ng generate component post
This will generate the four files necessary for a component. In the src/app directory, there will be a new directory, called post, with four files called post.component.ts, post.component.html ...