I established a shared service with the following Subject:
totalCostSource$ = new Subject<number>();
shareCost(cost: number ) {
this.totalCostSource$.next(cost);
}
Within my component, I have the following code:
private incomeTax: number = 18;
income: number;
constructor(private costService: CostService) { }
ngOnInit() {
this.costSubsription = this.costService.totalCostSource$.subscribe( cost => {
this.income = cost * this.incomeTax / 100;
console.log(this.income); // displays correct value in console
});
}
However, I am facing an issue with updating the income variable in my view. Even though the correct value is displayed in the console, the view does not refresh. How can I resolve this problem?