Through my AngularJS application I make calls to an API that return JSON in the following format:
[Object, Object]
0: Object
$$hashKey: "01"
Contact Name: "Michae"
Phone Number: "2000000000000"
As it is shown keys in JSON have spaces, so I used the following code in my app template to display the json content:
<select ng-model ="sortorder">
<option selected value="{{contacts['Contact Name']}}">Name</option>
<option selected value="{{contacts['Phone Number']}}">Contact Name</option>
</select>
<br><br><br>
<div ng-repeat="contacts in mContactsList | orderBy:sortorder">
<p>Contact Name: {{contacts['Contact Name']}}</p><br>
<p>Phone: {{contacts['Phone Number']}}</p><br>
</div>
In controller, I tried using:
$scope.sortorder = 'Contact Name'; and $scope.sortorder = '{{contacts[\'Contact Name\']}}';
but none worked...
The problem I am having now is that sorting is not working at all, so can someone please help me by pointing out what exactly I am doing wrong / missing? Any example is highly appreciated
Thanks