diff --git a/.gitignore b/.gitignore index b713cef55..cdcce561b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ node_modules # webstorm files .idea +*.iml diff --git a/src/state.js b/src/state.js index aa75e7024..b2bed1a88 100644 --- a/src/state.js +++ b/src/state.js @@ -166,10 +166,12 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { var toPath = to.path, from = $state.$current, fromParams = $state.params, fromPath = from.path; + var reloadWild = ($state.current.reloadWild === undefined || $state.current.reloadWild); + // Starting from the root of the path, keep all levels that haven't changed var keep, state, locals = root.locals, toLocals = []; for (keep = 0, state = toPath[keep]; - state && state === fromPath[keep] && equalForKeys(toParams, fromParams, state.ownParams); + state && state === fromPath[keep] && equalForKeys(toParams, fromParams, state.ownParams, reloadWild); keep++, state = toPath[keep]) { locals = toLocals[keep] = state.locals; } @@ -182,12 +184,17 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { $state.transition = null; return $q.when($state.current); } - // Normalize/filter parameters before we pass them to event handlers etc. var normalizedToParams = {}; forEach(to.params, function (name) { - var value = toParams[name]; - normalizedToParams[name] = (value != null) ? String(value) : null; + if(name === '*'){ + for(var key in toParams) { + normalizedToParams[key] = toParams[key]; + } + } else { + var value = toParams[name]; + normalizedToParams[name] = (value != null) ? String(value) : null; + } }); toParams = normalizedToParams; @@ -286,7 +293,13 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { else { $stateParams = {}; forEach(state.params, function (name) { - $stateParams[name] = params[name]; + if(name === '*'){ + for(var key in params){ + $stateParams[key] = params[key]; + } + } else { + $stateParams[name] = params[name]; + } }); } var locals = { $stateParams: $stateParams }; @@ -345,7 +358,10 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { }); } - function equalForKeys(a, b, keys) { + function equalForKeys(a, b, keys, reloadWild) { + if(keys.indexOf('*') > 0 && a != b && reloadWild){ + return false; + } for (var i=0; i