Personally i would parse the entire object in a service and have a result
like this:
$scope.collection = {
collumns: ['Name', 'SummerSalary', 'FirstYear', 'SecondYear',
'Benefits', 'ProBono'],
data: [{
name: 'Benefits',
data: [{
"Name": ["Allen And Ouvery", "1234"],
"SummerSalary": "37,000",
"FirstYear": "47000.00",
"SecondYear": "90,000",
"Benefits": "Corporate gym m’ship, STL, subsd restaurant, pension,
pte healthcare",
"ProBono": "300hrs"
}, {
"Name": ["Allen And", "4321"],
"SummerSalary": "37,00",
"FirstYear": "4700",
"SecondYear": "90,00",
"Benefits": "Corporate STL, subsd restaurant, pension, pte
healthcare",
"ProBono": "400hrs"
}, {
"Name": ["Allen Ouvery", "456"],
"SummerSalary": "37,00",
"FirstYear": "47000",
"SecondYear": "90000",
"Benefits": "Corporate restaurant, pension, pte healthcare",
"ProBono": "700hrs"
}]
}, {
name: 'Size',
data: [{
"Name": ["bb"],
"SummerSalary": "37,000",
"FirstYear": "47,000",
"SecondYear": "90,000",
"Benefits": "Corporate gym m’ship, STL, subsd restaurant, pension,
pte healthcare",
"ProBono": "300hrs"
}, {
"Name": ["bbb"],
"SummerSalary": "37,00",
"FirstYear": "4700",
"SecondYear": "90,00",
"Benefits": "Corporate STL, subsd restaurant, pension, pte
healthcare",
"ProBono": "400hrs"
}, {
"Name": ["bbbb"],
"SummerSalary": "37,00",
"FirstYear": "47000",
"SecondYear": "90000",
"Benefits": "Corporate restaurant, pension, pte healthcare",
"ProBono": "700hrs"
}]
}, {
name: 'Application and Selection',
data: [{
"Name": ["ccc"],
"SummerSalary": "37,000",
"FirstYear": "47,000",
"SecondYear": "90,000",
"Benefits": "Corporate gym m’ship, STL, subsd restaurant, pension,
pte healthcare",
"ProBono": "300hrs",
"Pro": "300hrs"
}, {
"Name": ["cccc"],
"SummerSalary": "37,00",
"FirstYear": "4700",
"SecondYear": "90,00",
"Benefits": "Corporate STL, subsd restaurant, pension, pte
healthcare",
"ProBono": "400hrs",
"Pro": "300hrs"
}, {
"Name": ["cccy"],
"SummerSalary": "37,00",
"FirstYear": "47000",
"SecondYear": "90000",
"Benefits": "Corporate restaurant, pension, pte healthcare",
"ProBono": "700hrs",
"Pro": "300hrs"
}]
}, {
name: 'Diversity Profile',
data: [{
"Name": ["dddd"],
"SummerSalary": "37,000",
"FirstYear": "47,000",
"SecondYear": "90,000",
"Benefits": "Corporate gym m’ship, STL, subsd restaurant, pension,
pte healthcare",
"ProBono": "300hrs"
}, {
"Name": ["ddddd"],
"SummerSalary": "37,00",
"FirstYear": "4700",
"SecondYear": "90,00",
"Benefits": "Corporate STL, subsd restaurant, pension, pte
healthcare",
"ProBono": "400hrs"
}, {
"Name": ["dddddd"],
"SummerSalary": "37,00",
"FirstYear": "47000",
"SecondYear": "90000",
"Benefits": "Corporate restaurant, pension, pte healthcare",
"ProBono": "700hrs"
}]
}]
};
After that you can change your view and use the *orderBy* filter that can
filter only arrays:
<div class="tab-pane white-bg fade" ng-repeat="table in collection.data">
<table class="table table-hover">
<thead>
<tr>
<th ng-repeat="collumn in collection.collumns">
<a ng-click="table.order=collumn;
table.direction=!table.direction">{{collumn}} <i
ng-class="{glyphicon:table.order === collumn, 'glyphicon-chevron-up':
table.order === collumn && table.direction, 'glyphicon-chevron-down':
table.order === collumn && !table.direction}"></i></a>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in table.data | orderBy:table.order:table.direction">
<td ng-repeat="collumn in collection.collumns">
<span ng-if="$first">{{record[collumn][0]}}</span>
<span ng-if="!$first">{{record[collumn]}}</span>
</td>
</tr>
</tbody>
</table>
</div>
You can try this here:
http://plnkr.co/edit/yXtuAt90u5hRnSt9pfEm?p=preview
On Friday, November 21, 2014 10:57:24 PM UTC+2, Leonard Modoran wrote:
>
> Hi to all,
>
> this is my first post, so with this occasion I'm saluting all the
> AngularJs community.
>
>
>
> My problem is the following: I have a json file, that need to be outputted
> in a table format. The problem is the famous default sorting by name, of
> that Json.
>
> I've have tried to put an example here:
>
> http://plnkr.co/edit/abTTHCYsODbYZ0jrR9c7?p=preview
>
> in which the last column is the $$hashKey, which I don't want
>
> Also I have some problems in sorting the content inside the table (not the
> titles), because of the multiple key and value in ng-repeat. If anyone has
> a better idea to do this, the help will be highly appreciated.
>
>
> Thank you!
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.