The promise returns a value but I don\'t seem to be assigning the value properly in the subscribe method.
import { Component } from \'@angular/core\';
import {
component context "this" is not available inside of the subscribe(), to fix this, declare _this and assign this before the subscribe() as shown below;
constructor (private dataService: DataService){
const _this = this;
dataService.getCompaniesCount().subscribe(res => {
this.companyCount = res.count; // does't work
});
dataService.getCompaniesCount().subscribe(res => { _this.companyCount = res.count; //works
});
}