I'm not sure what you're saying exactly. But I wanted to call out something
that you're doing ... that Sander inadvertently perpetuates while trying to
help you in a literal way ... that I think is bad practice.
I think it's unwise to put logic in the view. What you want to do is more
easily handled in the controller.
So instead of this in your index.html ... and then fighting it later:
... let the controller do the work:
<!-- inside index.html -->
<th data-ng-repeat="key in ::keys">
// inside app.js
function init(data) {
$scope.comparisonLists = data;
// Get the keys (col headers) from first data element
var first = data[Object.keys(data)[0]][0];
$scope.keys = first && Object.keys(first);
}
Notice that you don't have to filter out the "$" keys because Ng doesn't
add them until you bind ... and you haven't bound yet.
Among the many virtues of moving the logic to the controller: you can
filter keys you don't want (for other reasons), have different key sets,
rearrange the key set order statically or on-demand.
The point is that the controller is your friend. It's there to support the
view. Don't put view logic in the view; put it in the controller ... and
your troubles melt away.
Cheers,
Ward
p.s.: your plunker revisited in this manner:
http://plnkr.co/edit/dFrBtImgSVReCvdtiwY6?p=preview
--
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.