Angular First App

πŸš€ Build Your First Angular App

1️⃣ Install Angular CLI

Open your terminal (CMD/PowerShell):

npm install -g @angular/cli

2️⃣ Create a New Angular Project

ng new first-app

CLI will ask:

  • Add Angular routing? β†’ Yes

  • Stylesheet format? β†’ CSS

This creates a folder named first-app with all Angular files.


3️⃣ Run the App

cd first-app
ng serve

Now open your browser β†’
πŸ‘‰ http://localhost:4200/

You will see the Angular default welcome page. πŸŽ‰


🧩 4️⃣ Create Your First Component

Let’s create a component called hello:

ng g c hello

Angular creates:

hello/
β”œβ”€β”€ hello.component.ts
β”œβ”€β”€ hello.component.html
β”œβ”€β”€ hello.component.css

✏️ 5️⃣ Write Some Content in Your Component

Open hello.component.html and add:



 


πŸ“Œ 6️⃣ Display the Component on the Page

Open app.component.html and add:



 

Now check the browserβ€”your message appears!


πŸ”„ 7️⃣ Add Data Binding Example

In hello.component.ts:



 

In hello.component.html:



 

Angular automatically updates the UI. βœ”οΈ


🌐 8️⃣ Add a Button (Event Binding Example)

hello.component.html



 

hello.component.ts



 


🧠 What You Learned

By now you have built a functioning Angular app with:

βœ… Component creation
βœ… HTML templates
βœ… Data binding
βœ… Event handling
βœ… First working UI

You may also like...