I'm trying to get an understanding in how to map the result from a service call to an object using http.get and Observables in Angular 2.
Take a look at this Plunk
In the method getPersonWithGetProperty I'm expecting to return an Observable of type PersonWithGetProperty. However! I can't access the property fullName. I guess that I would have to create a new instance of the class PersonWithGetProperty and map the response to this new object using the class constructor. But how do you do that in the method getPersonWithGetProperty?
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Rx';
export class PersonWithGetProperty {
  constructor(public firstName: string, public lastName: string){}
  get fullName(): string {
    return this.firstName + ' ' + this.lastName;
  }
}
@Injectable()
export class PersonService {
    constructor(private http: Http) {
    }
    getPersonWithGetProperty(): Observable<PersonWithGetProperty> {
        return this.http.get('data/person.json')
         .map((response: Response) => <PersonWithGetProperty>(response.json()));
    }
}
 
    