I can't figure out how to map json object array returned from web service to correctly typed object array in Angular 2 application.
As you can see in Angular 2's official example in plunker, the expected objects are not of Hero type, they are of type Object and the heroes:Hero[] member of HeroListComponent is actually a Object[]. You can see in console that the array is not strongly typed:
http://plnkr.co/edit/Qa22yzPh3JWI8lNZ99Ik?p=preview
I added extra console.log() call to add hero command, you can see in browser console that we don't have a Hero[] but Object[].
So apparently here the conversion does not work:
this.http.get(this._heroesUrl)
.map(res => <Hero[]> res.json().data)
.catch(this.handleError);
and we get Object[] instead of Hero[].
Any ideas about how to map json to correctly typed objects?
More info: https://angular.io/docs/ts/latest/guide/server-communication.html