I need to connect my backend to my front. My front is Angular2+TS.
So the problem is in the service and the component. I can't figure out the syntax.
Service:
getCases(){
return this.http.get('some URL')
--- what code here? ---
}
At the moment my Component looks like:
export class CaseListComponent {
name: string;
id: string;
time: string;
cases: Observable<Case[]>;
constructor(public _service: Service, public _router: Router) {
this.cases = this._service.getCases()
.map((items) => items.map((item) => new Case(this.id, this.name, this.time)));
}
}
At the moment the code in the constructor gives compile error:
"Property 'map' does not exist on type 'Response'.
So apparently I also need to add something in the getCases
method in the service.
The template:
<table>
<tr *ngFor="let case of cases | async">
<td>{{case.name}}</td>
</tr>
</table>