Hello,
That's great. You almost have it.
The reason why the UI is not getting updated is because the scope changes inside of a callback method and the digest method is not being called. You can read more about it here.
Luckily, Angular offers several methods to force a scope update. I have tried the following in your Component class and it works as expected. Let me know what you think.
import {Component, OnInit, ChangeDetectorRef} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
public calories: number;
constructor(private cd: ChangeDetectorRef) {}
ngOnInit(): void {
COBI.tourService.calories.subscribe(calories => {
this.calories = calories;
this.cd.detectChanges();
});
}
public displayCalories(): void {
}
}
Best regards,
... View more