I am trying to assgin values to a type in my component. My subscribe is returing this when I do console.log
this.srvice.getTasks(this.request).subscribe(heroes => console.log(heroes));
{
"List": [
{
"id": 17,
"pro": 1,
"name": "Ram",
"UserId": 2,
"duedate": "2018-01-01T00:00:00",
"status": 1,
"active": false
},
{
"id": 3,
"pro": 1,
"name": "My Name",
"UserId": 1,
"duedate": "2018-01-01T00:00:00",
"status": 2,
"active": false
},
]
}
But when I am doing my assignment, it is not working.. I think It needs direct list to be supplied but my object is wrapped in "List". how can I extract this? I am new to angular
This is how I am assigning the values
Component Class:
model: dtoModel = {
List : []
};
this.taskService.getTasks(this.request).subscribe(heroes => this.model = heroes);
Models
export interface dto {
id: number;
pro: number;
name: string;
UserId: number;
duedate: string;
status: number;
active: boolean;
}
export interface dtoModel {
List: dto[];
}
In service
getTasks (requestSearch: TaskRequest): Observable<dto[]> {
return this.http.post<dto[]>(this.Url, requestSearch, httpOptions);
}