aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2011-02-01 20:16:30 -0800
committerIgor Minar2011-02-07 23:56:33 -0800
commit8724e97b7e6638797d3607a45682ef0b76311aae (patch)
tree627d79a43d1180d3ee820c935e1fa6322978091a /src
parentbf8013ad57ce30639bb37e7c0b8cf99cab8be650 (diff)
downloadangular.js-8724e97b7e6638797d3607a45682ef0b76311aae.tar.bz2
$route redirection should interpolate variables
Diffstat (limited to 'src')
-rw-r--r--src/services.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/services.js b/src/services.js
index b215dcdf..9dfdd35e 100644
--- a/src/services.js
+++ b/src/services.js
@@ -801,7 +801,7 @@ angularServiceInject('$route', function(location, $updateView) {
}
};
function updateRoute(){
- var childScope, routeParams, pathParams;
+ var childScope, routeParams, pathParams, redirectPath, segmentMatch, key;
$route.current = _null;
forEach(routes, function(rParams, rPath) {
@@ -817,7 +817,18 @@ angularServiceInject('$route', function(location, $updateView) {
if(routeParams) {
if (routeParams.redirectTo) {
- location.updateHash(routeParams.redirectTo);
+ redirectPath = '';
+ forEach(routeParams.redirectTo.split(':'), function(segment, i) {
+ if (i==0) {
+ redirectPath += segment;
+ } else {
+ segmentMatch = segment.match(/(\w+)(.*)/);
+ key = segmentMatch[1];
+ redirectPath += pathParams[key] || location.hashSearch[key];
+ redirectPath += segmentMatch[2] || '';
+ }
+ });
+ location.updateHash(redirectPath);
$updateView(); //TODO this is to work around the $location<=>$browser issues
return;
}