Recently, I created a component that contains an array of strings. Here's the code snippet for reference:
import {Component} from '@angular/core';
@Component({
selector: 'app-products-list',
templateUrl: './products-list.component.html',
styleUrls: ['./products-list.component.css']
})
export class ProductsListComponent {
products = ['test1', 'test2', 'test3'];
constructor() {
}
}
After defining the array, I tried to display it in my HTML file (products-list.component.html). This is how I included it:
<p>products-list works!</p>
<ul>
<li *ngFor='let product in products'>
{{product}}
</li>
</ul>
I noticed that when I run this in Angular, it only displays the paragraph tag "products-list works!" and not any of the strings from the array as list items. Can someone explain why this might be happening? I apologize if this is a trivial question, but I am still new to learning Angular.