Rendering a List with *ngFor in Angular
📖 Scenario: You are building a simple Angular component to display a list of favorite fruits on a webpage. The list should show each fruit name as a separate item.
🎯 Goal: Create an Angular standalone component that uses *ngFor to render a list of fruits inside an unordered list (<ul>). Each fruit should appear as a list item (<li>).
📋 What You'll Learn
Create a component with a property called
fruits that holds an array of strings.Add a configuration variable called
title with the value 'My Favorite Fruits'.Use
*ngFor in the template to loop over fruits and display each fruit inside an <li> element.Add a heading
<h2> that displays the title above the list.💡 Why This Matters
🌍 Real World
Rendering lists dynamically is common in web apps, such as showing products, messages, or user data.
💼 Career
Understanding *ngFor is essential for Angular developers to build interactive and data-driven user interfaces.
Progress0 / 4 steps