A new challenge has arisen that involves a specific class:
import { HttpClient } from '../services/http.service'
export class Project {
constructor(
private http: HttpClient
){
}
@JsonProperty('name')
title: string;
id:string;
public getTitle(): string {
return this.title;
}
public getId(): string {
return this.id;
}
public removeProject() {
return this.http.delete("deleteurl"+this.id).map(() => {
return true;
})
}
}
The main goal is to properly deserialize json objects like this:
import { JsonConvert } from "json2typescript";
getProjects():Observable<Project[]> {
return this.http.get("getprojects").map((res:Response) => {
var array: Project[] = [];
for (let entry of res.json().files) {
array.push(JsonConvert.deserializeObject(entry, Project));
}
return array;
})
}
An issue arises when attempting to map the json data to the classes due to an error linked to the injected HTTP service within the Project class
How do you suggest handling this? What would be considered best practice in this situation?