Question from the Angular test

Why is the following snippet not validated? ```jsx <h1>Products Lists</h1> <ul> <li *ngFor="let p of products" *ngIf="p.stock > 0"> {{ p.name }} </li> </ul> ``` Answer: We cannot have ngFor and ngIf on the same element

Easy

Why is the following snippet not validated?

<h1>Products Lists</h1>

<ul>
   <li *ngFor="let p of products" *ngIf="p.stock > 0"> {{ p.name }} </li>
</ul>
Author: Emmanuel DemeyStatus: PublishedQuestion passed 2641 times
Edit
5
Community Evaluations
developer avatar
No
26/06/2024
NW : The provided Angular snippet is not valid because we cannot have both *ngFor and *ngIf on the same element. Angular's structural directives (*ngFor, *ngIf, etc.) cannot be combined directly on the same element because they both transform the DOM in different ways.