I have a function that returns an Observable when a row in a table is clicked.
private onEnrollmentHistory(val: Enrollment[]) {
this.enrollments = val;
console.log(this.enrollments);
}
getEnrollmentHistoryById(id: number) {
this.toggleMoreInfoDialog();
return this.store.getEnrollmentHistoryById(id)
.subscribe(
this.onEnrollmentHistory
);
}
I'm not sure how to get this info into the component HTML.
I can't do <div *ngFor="let enroll of someService | async"> because the ID isn't known until someone clicks on it. Is there some syntax I'm missing to have some text in a div bound to this Observable? something like
<div (ngModel)="this.bSubject.getValue()">?
the function is called from a table row
<td>
(click)="getEnrollmentHistoryById(id)" class="fa fa-2x fa-info">
</td>
<div class="container">
<div class="row">
here are enrollments
<div *ngFor="let e of enrollments">
{{e}}
</div>
</div>
</div>
This is meant to be read only, I just need grab something from the DB with the observable, and show it on the page on a click event.
(click)event is bound. - Dhyey<div>{{ bSubject.getValue() }}</div>. Not even sure why you use a BeahaviorSubject to store the value, instead of just storing the value in your component directly. - JB Nizet