Created
February 21, 2014 19:13
-
-
Save dillonforrest/9141238 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('campfire', [ | |
'templates-app', | |
'templates-common', | |
'ngBoilerplate.home', | |
'ngBoilerplate.about', | |
'ui.state', | |
'ui.route', | |
'UserSrvc' | |
]) | |
.config(['$stateProvider', '$urlRouterProvider', | |
function myAppConfig($stateProvider, $urlRouterProvider) { | |
$stateProvider | |
.state('apples', { | |
url : '/apples', | |
template : '<p>apples</p>' | |
}) | |
.state('bananas', { | |
url : '/bananas', | |
template : '<p>bananas</p>' | |
}) | |
.state('login', { | |
url : '/login', | |
template : '<p>login</p>' | |
}) | |
; | |
$urlRouterProvider.otherwise('login'); | |
}]) | |
.run(['$rootScope', '$location', 'UserService', | |
function run($rootScope, $location, User) { | |
$rootScope.$on('$locationChangeStart', | |
function checkLogin(evt, newRoute, oldRoute) { | |
if (!User.loggedIn) { | |
evt.preventDefault(); | |
$location.path('/login'); | |
$location.replace(); | |
} | |
}); | |
}]) | |
.controller('AppCtrl', function AppCtrl($scope, $location) { | |
$scope.$on('$stateChangeSuccess', | |
function(event, toState, toParams, fromState, fromParams){ | |
if ( angular.isDefined(toState.data && toState.data.pageTitle) ) { | |
$scope.pageTitle = toState.data.pageTitle + ' | TripleLift' ; | |
} else { | |
$scope.pageTitle = 'TripleLift'; | |
} | |
}); | |
}) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment