Skip to content

Instantly share code, notes, and snippets.

@kapv89
Created June 19, 2013 20:13
Show Gist options
  • Save kapv89/5817633 to your computer and use it in GitHub Desktop.
Save kapv89/5817633 to your computer and use it in GitHub Desktop.
angular.module('sorter').controller('AppCtrl', function ($scope, $uri, $route, $location, $window) {
var navItem = function (slug) {
var item = {
title : slug[0].toUpperCase() + slug.slice(1),
slug : slug,
uri : $uri.page(slug)
};
item.isActive = function () {
return this.uri === $location.path();
};
return item;
}
$scope.navItems = [navItem('artists'), navItem('events'), navItem('videos'), navItem('songs')];
var loadComponents = function () {
$scope.filterTmpl = $route.current.filterTmpl
$scope.listingTmpl = $route.current.listingTmpl
$scope.weightManagerTmpl = $route.current.weightManagerTmpl
};
$scope.$on('auth-failed', function ($ev) {
$window.location.reload();
});
$scope.$on('$routeChangeSuccess', function ($ev, $cur, $prev) {
loadComponents();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment