|I've been struggling with getting an Angular 6 app to sort the results of an WebAPI call, and it turns out that the root cause is case sensitivity on the object properties. And I can see 'where' the differing cases come from, but I can't see the where/why.
I have a class for my object:
export class App
}And my web service returns JSON like:
,"Name":"Matterhorn User Management"
,"Description":"User and Role management for Matterhorn applications."
,"DisplayOrder":10}To retrieve the data I've got the following function in my service:
let apiURL: string = this.baseUrl + 'usermanagement/applications/read';
And finally my component calls that service function:
this.apps = data.sort((a, b) => a.DisplayOrder - b.DisplayOrder);
So the problem was that
data structure matches the JSON capitalization and not my local TS object one, and I had to use
displayOrder (and TS now whinges at me).
But isn't Angular now supposed to map and convert JSON automatically (I know this was a specific step in the past)?
And surely your local objects don't have to match the case sensitivity of the JSON provided by others.
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
Copyright © CodeProject
All Rights Reserved.