It's very easy to create your own component.
Basically, two ways we can create our own components.
- Manual
- Autometic with CLI command
Manual
Step 1: Create a new folder inside app folder. Follow the naming convention of a folder. Give the folder name as the module name. Like - login.
Step 2: Create your own .ts file, .html file, and .css file inside your 'login' folder. Here also follow the naming convention.
- login.component.ts > Add your selector
- login.component.html > Write your HTML code here for your own component.
- login.component.css > Write here CSS code for your own HTML file.
Step 3: Add your type script(login.component.ts) class in the app.module.ts
Step 4: Lastly, add your selector which you created in login.component.ts file with another HTML file. Like - app.component.html
Step 5: All processes are done. Now check in the browser.
Step 1: Open the terminal and run the below command.
ng generate component homeorng g c home
0 Comments