Is there a way to filter and search for the item name when the item details are sourced from another JSON object?
Demo: http://codepen.io/anon/pen/GjAxKX
While the rest of the filtering and ordering functionalities are functioning correctly, I am struggling with finding a solution for the item section regarding orderBy
and filter
.
angular.module('mytodos', ['ui.bootstrap']).controller('TodoController', function($scope) {
$scope.changeNum = function(itemNum) {
$scope.numPerPage = itemNum;
};
$scope.numsForPage = [5, 10, 25, 50, 100];
$scope.currentPage = 1;
$scope.numPerPage = 5;
$scope.maxSize = 5;
// Sort
$scope.changeSort = function(item) {
$scope.reverse = $scope.reverse = !$scope.reverse;
$scope.sort = item;
};
$scope.filteredTodos = [];
$scope.currentPage = 1;
$scope.numPerPage = 5;
$scope.maxSize = 5;
$scope.expenses = [{ ... }];
$scope.theItems = {
1: {
'name': 'TV',
'models': [1]
},
2: {
'name': 'Radio',
'models': [2, 3, 4, 5]
},
...
}).filter('pagination', function() {
return function(input, currentPage, pageSize) {
if (angular.isArray(input)) {
var start = (currentPage - 1) * pageSize;
var end = currentPage * pageSize;
return input.slice(start, end);
}
};
});
.box { ... }
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
...