- Get link
- X
- Other Apps
Components are the main building block for Angular applications. Each component consists of:-
- An HTML template that declares what renders on the page
- A Typescript class that defines behavior
- A CSS selector that defines how the component is used in a template
- Optionally, CSS styles applied to the template
Creating a component:
The easiest way to create a component is with the Angular CLI. You can also create a component manually.
Creating a component using the Angular CLI
To create a component using the Angular CLI.
- From a terminal window, navigate to the directory containing your application.
- Run the ng generate component <component-name> command, where <component-name> is the name of your new component.
Example:-
If you want to create Home component then open cli and write below command to create Home Component.
ng generate component Home (OR) ng g g Home
Component Contains
- A folder named after the component
- A component file, <component-name>.component.ts
- A template file, <component-name>.component.html
- A CSS file, <component-name>.component.css
- A testing specification file, <component-name>.component.spec.ts
Comments
Post a Comment
if you have questions please let me know