Skip to content

Instantly share code, notes, and snippets.

@gajus
Created September 26, 2014 12:40
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/5a1e494cfae10604883c to your computer and use it in GitHub Desktop.
Save gajus/5a1e494cfae10604883c 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 : '';
};
});
@gajus
Copy link
Author

gajus commented Sep 26, 2014

Defining AngularJS constants and importing them using dependency injection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment