In my template, I need to display the text 'Passed' only if item.name === 'michael'is not true.My component has data courses[] coming from its parent. I have two interfaces Courses and Teachers where each course id has its own Teacher data.
Here is my code:
@Input() courses[];
isRequired = false;
ngonInit() {
for (const entry of courses ) {
this.onCheckData(entry);
}
}
onCheckData(singleList: Courses) {
this.someService.someObservable(singleList.id).subscribe( item => {
if (item.name === 'michael') {
this.isRequired = true;
}
});
}
declare interface courses {
id: number;
name: string;
price: number;
}
declare interface Teachers {
name : string;
address: string;
}
Setting true/false with variable isRequired does not seem to work. someObservable() is returning an Observable<Teacher> using http.
<tbody>
<tr *ngFor="let listing of courses">
<td>
{{listing.name}}
</td>
<td>
<span *ngIf="!isRequired"> Passed </span> // not working here
</td>
</tbody>