Let's say I have two Angular filters: translate
, which manipulates strings in some way, and sort
, which sorts strings alphabetically. I want to display strings from an array str
sorted based on their translation. Here is the code I want to make work:
<div ng-repeat="s in strs | translate | sort">{{ s }}</div>
This code doesn't work because translate
acts on individual strings and not arrays of strings like I need it to. I need a way to apply translate
to arrays such as strs
within the Angular expression.
How can I elegantly achieve this functionality in Angular?
For example, if translate
converts strings 'a'
, 'b'
, 'c'
to 'z'
, 'y'
, 'x'
respectively, I want the HTML output to be:
<div>c</div> <div>b</div> <div>a</div>