Last active
August 29, 2015 14:13
-
-
Save gynsolomon/bfee1c81b2eb478d896f to your computer and use it in GitHub Desktop.
This is a helper for combining usage of ngRoute & ui-router together.
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
/** | |
* 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