Created
September 26, 2014 12:40
-
-
Save gajus/5a1e494cfae10604883c to your computer and use it in GitHub Desktop.
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
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
Defining AngularJS constants and importing them using dependency injection.