angular.module('app') .controller('articlesController', ['$scope', '$stateParams', 'articlesBusiness', 'listControllerBuilder', function($scope, $stateParams, articlesBusiness, listControllerBuilder) { $scope.business = articlesBusiness; $scope.itemType = 'articles'; $scope.defaultOrder = 'id'; listControllerBuilder.create($scope, $stateParams); $scope.getAddItem = function() { return { title: $scope.query.filter }; }; $scope.getFilter = function (filter) { var label = $scope.appUtils.tr('articles.type').toLowerCase(); return filter.replace(new RegExp(label + ': *([a-zA-Z0-9]*)'), function(match, p1) { var type = null; for (var t in $scope.appUtils.articleTypes) { var str = $scope.appUtils.articleTypes[t]; if ($scope.appUtils.tr('articles.types.' + str).toLowerCase() == p1.toLowerCase()) { type = str; break; } } return type == null ? '' : 'type:' + type; }); }; $scope.init(); }]);