My observable is populated in the following manner:
this._mySubscription = this._myService.fetchData(id)
.subscribe(
response => this._myData = response,
error => this.displayError(<any>error),
() => this.stopLoading()
);
In my HTML markup, I can access its properties using the Elvis operator like so:
{{_myData?.PropertyNameHere}}
However, how can I access the same property in the component using TypeScript?
Attempting to do so results in a red squiggly line under the property:
this._myData.PropertyNameHere
And displays the error message:
Property does not exist on Observable
Update: Example of service call
fetchData(id: string): Observable<any> {
let params = 'id=' + id;
return this._http
.post(apiUrl + 'SomeController/SomeAction', params, {withCredentials: true, headers: this.headers})
.timeoutWith(maxTimeHttpCalls, Observable.defer(() => Observable.throw(this._feedbackService.timeout())))
.map((response: Response) => response.json().data.Items);
}