Skip to content

Instantly share code, notes, and snippets.

@gynsolomon
Last active August 29, 2015 14:13
Show Gist options
  • Save gynsolomon/bfee1c81b2eb478d896f to your computer and use it in GitHub Desktop.
Save gynsolomon/bfee1c81b2eb478d896f to your computer and use it in GitHub Desktop.
This is a helper for combining usage of ngRoute & ui-router together.
/**
* Created by solomon on 15/1/14.
*/
+function () {
angular.module('ui.router.otherwise',['ui.router'])
.provider('otherwise', ['$urlRouterProvider', function ($urlRouterProvider) {
var url = '';
this.path = function (url) {
$urlRouterProvider.otherwise(function ($injector, $location) {
$('body>[ui-view]').html('');
var routes = $injector.get('$route').routes;
for(var key in routes){
if(routes[key].regexp.test($location.$$url))
return $location.$$url;
}
return url;
});
};
this.$get = function(){
return {
url: url
}
};
}]);
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment