Adding Filters to Directives
Filters are added to directives, likeng-repeat
, by using the pipe character
|
, followed by a filter:Example
TheorderBy
filter sorts an array:
<div ng-app="myApp" ng-controller="namesCtrl">
<ul>
<li ng-repeat="x in names | orderBy:'country'">
{{ x.name + ', ' + x.country }}
</li>
</ul>
</div>