Issue
I have data form as below
{
"COLUMNS": ["Col1", "Col2", "Col3", "Col4", "Col5"],
"DATA": [
[Test, Test, Test, Test, Test],
[Test, Test, Test, Test, Test]
]
}
I want to split this data two pieces in my service and i want to get my columns and data seperate.
I try to use .shift() method as below but it's return undefined.
My service:
getService(): any{
this.http.get<string[]>(this.url2).pipe(map(data => {
return data.shift()
}))
}
My component:
ngOnInit(): void {
this.columns = this.productService.getProductsService();
}
What am i doing wrong?
Solution
I fixed my problem . Here my solution
public general : any[];
public columns : string[];
public gridData: Test[];
this.productService.getProductsService().subscribe((res: Test[]) => {
this.general = res;
this.columns = Object.values(this.general).shift();
this.gridData = Object.values(this.general)[1];
});
Answered By - saulyasar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.