items array and the template below, what will be the rendered output inside the <ul> element?items = ['apple', 'banana', 'cherry']; Template: <ul> <li *ngFor="let item of items; let i = index">{{i}}: {{item}}</li> </ul>
index starts at 0 and is assigned to i.The *ngFor directive loops over items. The index variable starts at 0, so each <li> shows the index and the item. Option A matches this exactly.
*ngFor with a trackBy function?trackBy function named trackById. Which template syntax is correct?trackBy syntax uses a colon, not an equals sign or parentheses.The correct syntax for trackBy in *ngFor is trackBy: functionName without parentheses. Option C uses this correctly.
*ngFor code cause a runtime error?- User: {{user.name}}, Odd: {{odd}}
users = [{name: 'Anna'}, {name: 'Bob'}];
What is the cause of the runtime error?*ngFor supports.*ngFor supports index, first, last, even, and odd as local variables. However, you cannot assign let odd = odd because odd is a reserved keyword in this context. You must use a different variable name like let isOdd = odd.
selectedItem after this template interaction?- {{color}}
Selected: {{selectedItem}}
If the user clicks the second<li> (green), what is displayed in the paragraph?selectedItem to that item's value.Clicking the second <li> sets selectedItem to 'green'. The paragraph then shows 'Selected: green'.
*ngFor and change detection is true?*ngFor directive. Which statement correctly explains how trackBy affects performance?trackBy helps Angular identify items uniquely, so it can reuse existing DOM elements instead of recreating them, improving performance.
