2016-05-13 13:05:16 -04:00
|
|
|
/*
|
|
|
|
* Resources Controller
|
|
|
|
*
|
|
|
|
* This controller is responsible for fetching all the data for the resources page,
|
|
|
|
* from Firebase.
|
|
|
|
*/
|
2016-05-31 11:33:46 -04:00
|
|
|
angularIO.controller('ResourcesCtrl', ['$firebaseArray', '$firebaseObject','$location', function ($firebaseArray, $firebaseObject, $location) {
|
|
|
|
var DEFAULT_CATEGORY = 'education';
|
2016-05-13 13:05:16 -04:00
|
|
|
var categoryRef = new Firebase("https://angularresources.firebaseio.com/");
|
|
|
|
var vm = this;
|
|
|
|
|
|
|
|
vm.fbObject = $firebaseObject(categoryRef);
|
2016-05-31 11:33:46 -04:00
|
|
|
vm.selectedCategory = $location.hash() ? $location.hash() : DEFAULT_CATEGORY;
|
|
|
|
|
|
|
|
// onSelect :: String
|
|
|
|
// Side effect, modifies vm.selectedCategory
|
|
|
|
vm.onSelectCategory = function onSelectCategory(category) {
|
|
|
|
$location.hash(category);
|
|
|
|
vm.selectedCategory = category;
|
|
|
|
};
|
2016-05-13 13:05:16 -04:00
|
|
|
|
|
|
|
}]);
|