aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVojta Jina2011-09-01 16:04:18 +0200
committerVojta Jina2011-09-08 23:00:59 +0200
commit292d5d1421108c239d3270c22c49a9ccd1eea571 (patch)
treef55e080f81cfa822cd24b4c14fb35e5439242a27
parent66dec7755573a1c07a1fe8e0dd9bc5fc51dbaac9 (diff)
downloadangular.js-292d5d1421108c239d3270c22c49a9ccd1eea571.tar.bz2
refactor($route): remove some odd code and rename allowReload to forceReload
-rw-r--r--src/service/route.js12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/service/route.js b/src/service/route.js
index 4455e860..05cb62f8 100644
--- a/src/service/route.js
+++ b/src/service/route.js
@@ -119,7 +119,7 @@ angularServiceInject('$route', function($location, $routeParams) {
parentScope = this,
rootScope = this,
dirty = 0,
- allowReload = true,
+ forceReload = false,
$route = {
routes: routes,
@@ -189,7 +189,6 @@ angularServiceInject('$route', function($location, $routeParams) {
* Adds a new route definition to the `$route` service.
*/
when:function (path, route) {
- if (isUndefined(path)) return routes; //TODO(im): remove - not needed!
var routeDef = routes[path];
if (!routeDef) routeDef = routes[path] = {reloadOnSearch: true};
if (route) extend(routeDef, route); //TODO(im): what the heck? merge two route definitions?
@@ -225,7 +224,7 @@ angularServiceInject('$route', function($location, $routeParams) {
*/
reload: function() {
dirty++;
- allowReload = false;
+ forceReload = true;
}
};
@@ -235,7 +234,7 @@ angularServiceInject('$route', function($location, $routeParams) {
/////////////////////////////////////////////////////
- function switchRouteMatcher(on, when, dstName) {
+ function switchRouteMatcher(on, when) {
var regex = '^' + when.replace(/[\.\\\(\)\^\$]/g, "\$1") + '$',
params = [],
dst = {};
@@ -253,7 +252,6 @@ angularServiceInject('$route', function($location, $routeParams) {
forEach(params, function(name, index){
dst[name] = match[index + 1];
});
- if (dstName) this.$set(dstName, dst);
}
return match ? dst : null;
}
@@ -263,12 +261,12 @@ angularServiceInject('$route', function($location, $routeParams) {
last = $route.current;
if (next && last && next.$route === last.$route
- && equals(next.pathParams, last.pathParams) && !next.reloadOnSearch && allowReload) {
+ && equals(next.pathParams, last.pathParams) && !next.reloadOnSearch && !forceReload) {
$route.current = next;
copy(next.params, $routeParams);
last.scope && last.scope.$emit('$routeUpdate');
} else {
- allowReload = true;
+ forceReload = false;
rootScope.$broadcast('$beforeRouteChange', next, last);
last && last.scope && last.scope.$destroy();
$route.current = next;