June 2014
Intermediate to advanced
696 pages
38h 52m
English
A very common use of filters is to order or filter out dynamic elements built using the ng-repeat directive from JavaScript arrays. This section provides an example of implementing orderBy filters to generate a table that can be sorted by column and filtered by a string from an <input> element.
Listing 23.5 implements a controller that defines the $scope.cameras array to use as input data in the scope. Since you do not want to alter the actual model data when sorting and filtering, line 9 adds the $scope.filteredCameras property to store the filtered array.
Notice that line 10 sets a $scope.reverse value to keep track of the sort direction. Then line 11 sets a $scope.column value to keep track ...
Read now
Unlock full access