Skip to content

Instantly share code, notes, and snippets.

@gajus
Created September 26, 2014 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gajus/5ee40130f3a2409362b1 to your computer and use it in GitHub Desktop.
Save gajus/5ee40130f3a2409362b1 to your computer and use it in GitHub Desktop.
angular
.module('store')
.constant('productListActiveClass', 'active')
.controller('productListController', function ($scope, $filter, productListActiveClass) {
var selectedCategory = null;
$scope.selectCategory = function (categoryName) {
selectedCategory = categoryName;
};
$scope.categoryFilterFn = function (product) {
return !selectedCategory || product.category === selectedCategory;
};
$scope.getCategoryClass = function (categoryName) {
return categoryName == selectedCategory ? productListActiveClass : '';
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment