Skip to content

onBefore hook returning Promise<TargetState> does not work. #3334

Closed
@grant77

Description

@grant77

If I return just TargetState it works. But if the I return the TargetState from within a promise it does not. My hook looks like this

    function hook(transition) {
        var target = transition.router.stateService.target,
            targetState = transition.targetState(),
            targetStateInternal = targetState.state(),
            targetStateData = targetStateInternal && targetStateInternal.data,
            allowAnonymous = targetStateData && targetStateData.allowAnonymous;

        // Returning right here outside of promise will work.  Ie:
        // return target(loginStateName, { redirectTo: targetState.name(), redirectParams: targetState.params() });

        return !allowAnonymous ? signInManager.isSignedIn().then(noop, error) : null;

        function error() {
            return target(loginStateName, {
                redirectTo: targetState.name(),
                redirectParams: targetState.params()
            });
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions