Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6eb08ac

Browse files
committed
allow custom transitionTo options
1 parent 3b0efd2 commit 6eb08ac

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

‎src/middleware.factory.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,12 @@ function middlewareFactory($injector, $q) {
194194
*
195195
* @returns {void}
196196
*/
197-
function redirectTo(route, params) {
197+
function redirectTo(route, params,options) {
198198
middleware.resolution.reject({
199199
type: "redirectTo",
200200
route: route,
201-
params: params
201+
params: params,
202+
options: options
202203
});
203204
}
204205
}];

‎src/routers/uiRouter.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@ function handleMiddleware($rootScope, $state, $middleware) {
3333
// Prevent state change error from working normally
3434
event.preventDefault();
3535

36-
// Redirect, allowing reloading and preventing url param inheritance
37-
// https://github.com/angular-ui/ui-router/wiki/Quick-Reference#statetransitiontoto-toparams--options
38-
return $state.transitionTo(error.route, error.params, {
36+
// Use provided transitionTo options or use default
37+
var options = error.options || {
3938
location: true,
4039
inherit: false,
4140
relative: $state.$current,
4241
notify: true,
4342
reload: true
44-
});
43+
};
44+
45+
// Redirect, allowing reloading and preventing url param inheritance
46+
// https://github.com/angular-ui/ui-router/wiki/Quick-Reference#statetransitiontoto-toparams--options
47+
return $state.transitionTo(error.route, error.params, options);
4548
}
4649
});
4750
}]);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /