I am curious to see if it is possible to match a key in *ngfor
. Here is an example of my code on StackBlitz. However, when I try this method, it only displays No data
.
HTML
<ul>
<li *ngFor="let course of courses; index as i">
{{key == course.id? course.name :'No data' }}
</li>
</ul>
Component
courses = [
{ id:1, name:'course1' },
{ id:2, name:'course2' },
{ id:3, name:'course3' }
];
key = [1,2];
}