Last active
August 29, 2015 14:11
-
-
Save got5/f1b5c985d1e9edca3ffa to your computer and use it in GitHub Desktop.
Slide 140 TP9 filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<div class="lateral-form"> | |
Results per page: <br/> | |
<!-- TODO: Number of products displayed per page. --> | |
<input type="number" id="nbFilter" name="nbFilter" ng-model="nbResults"/> Filter by name: | |
<br/> | |
<!-- TODO --> | |
<input type="text" id="nameFilter" name="nameFilter" ng-model="nameFilter.name"/> <br/> Order | |
by: <br/> | |
<!-- TODO --> | |
<select name="bookOrderBy" id="bookOrderBy" ng-model="bookOrderBy"> | |
<option>name</option> | |
<option>price</option> | |
<option>rating</option> | |
</select> | |
<!-- TODO --> | |
<br/> Reverse filter: <input type="checkbox" ng-model="filterReverse"/> <br/> | |
</div> | |
<div class="k-catalog list-products"> | |
<!-- hproduct/ --> | |
<product-summary product="product" ng-repeat="product in products | filter:nameFilter | orderBy:bookOrderBy:filterReverse | startFrom:(currentPage - 1)* nbResults | limitTo:nbResults"/> | |
<!-- /hproducts --> | |
</div> | |
<div class="bloc-pagination"> | |
<pagination total-items="products.length" ng-model="currentPage" items-per-page="nbResults" class="pagination-sm" boundary-links="true" ></pagination> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.nbResults= 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="js/filters/startFrom.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
"use strict"; | |
/** Filter used to return a collection which only elements at or after a given index. */ | |
angular.module('app') | |
.filter('startFrom', function() { | |
return function(pArray, pStartIndex) { | |
if (pArray !== undefined && pArray !== null) { | |
var filteredArray = []; | |
filteredArray = pArray.slice(pStartIndex); | |
return filteredArray; | |
} | |
return pArray; | |
}; | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment