Skip to content

Commit fa43700

Browse files
committed
Merge pull request johnpapa#280 from johnpapa/develop
Develop
2 parents 872b885 + 4756538 commit fa43700

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,8 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
17731773
17741774
```javascript
17751775
/* recommended */
1776+
var handlingRouteChangeError = false;
1777+
17761778
function handleRoutingErrors() {
17771779
/**
17781780
* Route cancellation:
@@ -1781,14 +1783,25 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
17811783
*/
17821784
$rootScope.$on('$routeChangeError',
17831785
function(event, current, previous, rejection) {
1784-
var destination = (current && (current.title || current.name || current.loadedTemplateUrl)) ||
1786+
if (handlingRouteChangeError) { return; }
1787+
handlingRouteChangeError = true;
1788+
var destination = (current && (current.title ||
1789+
current.name || current.loadedTemplateUrl)) ||
17851790
'unknown target';
1786-
var msg = 'Error routing to ' + destination + '. ' + (rejection.msg || '');
1791+
var msg = 'Error routing to ' + destination + '. ' +
1792+
(rejection.msg || '');
1793+
17871794
/**
17881795
* Optionally log using a custom service or $log.
17891796
* (Don't forget to inject custom service)
17901797
*/
17911798
logger.warning(msg, [current]);
1799+
1800+
/**
1801+
* On routing error, go to another route/state.
1802+
*/
1803+
$location.path('/');
1804+
17921805
}
17931806
);
17941807
}
@@ -2010,7 +2023,7 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
20102023
20112024
*Why?*: Separates configuration from module definition, components, and active code.
20122025
2013-
*Why?*: Provides a identifiable place to set configuration for a module.
2026+
*Why?*: Provides an identifiable place to set configuration for a module.
20142027
20152028
### Routes
20162029
###### [Style [Y129](#style-y129)]

0 commit comments

Comments
 (0)