You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I checked the docs and see that redirectTo can contain a condition.
// a fn conditionally returning a {state, params}
.state('F', {
redirectTo: (trans) => {
if (trans.params().foo < 10)
return { state: 'F', params: { foo: 10 } };
}
})
In my own code, I check if the user is logged in. If he is, I redirect to another state. Otherwise, I just want to go to the requested state. The problem is that if the condition is not met an error occurs and we won't go in the state initially requested.
angular.js:13920 TypeError: Cannot read property 'state' of undefined
at handleResult (redirectTo.ts:25)
at processQueue (angular.js:16383)
at angular.js:16399
at Scope.$eval (angular.js:17682)
at Scope.$digest (angular.js:17495)
at Scope.$apply (angular.js:17790)
at angular.js:19621
at completeOutstandingRequest (angular.js:5964)
at angular.js:6243
As a workaround, I returned an empty object {} instead of nothing. It allows your code to go to the end without errors.
function handleResult(result: any) {
let $state = trans.router.stateService;
if (result instanceof TargetState) return result;
if (isString(result)) return $state.target(<any> result, trans.params(), trans.options());
if (result['state'] || result['params'])
return $state.target(result['state'] || trans.to(), result['params'] || trans.params(), trans.options());
}
The text was updated successfully, but these errors were encountered:
I checked the docs and see that redirectTo can contain a condition.
In my own code, I check if the user is logged in. If he is, I redirect to another state. Otherwise, I just want to go to the requested state. The problem is that if the condition is not met an error occurs and we won't go in the state initially requested.
As a workaround, I returned an empty object {} instead of nothing. It allows your code to go to the end without errors.
The text was updated successfully, but these errors were encountered: