Coming from a C# background, I'd thought this should work in typescript. I have a class which contains a read-only property that depends on other two properties in the class.
export class Foo {
bar1: number;
bar2: number;
get bar3(): boolean {
return this.bar1 > this.bar2;
}
}
Now in Angular 4 I have a service returning Observable e.g.
getFoos(fooId: number): Observable<Foo[]> {
return this.http.get(this.url)
.map((res: Response) => res.json());
}
Note that my REST api response does NOT return bar3
but only bar1
and bar2
.
Then in my component, when trying to access Foo[]
, its entry doesn't have bar3
property on it, only bar1
and bar2
.
So how to make bar3
populated?