I have an HTML table and want to sort my records ($scope.records
in ctrl) by clicking on table headers ($scope.headers
in ctrl),
Can anyone
Extending Gloopy's answer, yet another option is to modify the parent's properties in the ng-repeat for the primitive types:
{{ headers[$index] }}
Here is a fiddle.
Note however that $parent is not a documented property of scope, so this is somewhat of a hack, so use at your own risk.
I wish AngularJS had a better way of dealing with these "inner scopes" that are created by ng-repeat, ng-switch, etc. because quite often we need to modify parent scope properties that are primitives.
See also Gloopy's insightful comment about scope inheritance as it relates to primitives and non-primitives here.