Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit c9f2797

Browse files
committed
Update App.js
1 parent 4d533c0 commit c9f2797

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

modules/App.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
var module = angular.module('App', ['ui.router', 'App.Authentication', 'App.Guest']);
22

3-
4-
module.config(function($urlRouterProvider, $rootScope) {
3+
module.config(function($urlRouterProvider) {
4+
55
// Default URL if no matches
66
$urlRouterProvider.otherwise('/projects');
7+
8+
});
79

8-
// Global catching of uiRouter errors (for development)
9-
$rootScope.$on('stateChangeError', (event, toState, toParams, fromState, fromParams, error) => {
10-
console.log( event, toState, toParams, fromState, fromParams, error );
10+
module.run(function($rootScope){
11+
12+
$rootScope.$on('$stateChangeError', console.error.bind(console));
13+
14+
// Add support for a `redirectTo` property on state definitions for default children
15+
$rootScope.$on('$stateChangeStart', function(event, toState){
16+
if (toState.redirectTo) {
17+
if (angular.isFunction(toState.redirectTo)) {
18+
toState.redirectTo.apply(toState, [].slice.call(arguments));
19+
} else {
20+
event.preventDefault();
21+
$state.go(toState.redirectTo);
22+
}
23+
}
1124
});
25+
1226
});

0 commit comments

Comments
 (0)