Inject resolved value into onExit function. #3081

Closed
Dav1dde opened this Issue Oct 11, 2016 · 1 comment

Projects

None yet

2 participants

@Dav1dde
Dav1dde commented Oct 11, 2016

I have a state like this:

.state('design', {
    url: '/design',
    templateUrl: 'design.html',
    resolve: {
        cc: ['$stateParams', 'configuratorService', function ($stateParams, configuratorService) {
            return configuratorService.update($stateParams, true);
        }]
    },
    onExit: ['cc', '$state', function (cc, $state) {
        console.log(cc);
    }]
}

When I leave the state, I always get this exception: Error: [$injector:unpr] Unknown provider: ccProvider <- cc. This used to work with angular-ui-router v0.2.18.

I also tried basically any combination of $state.transition.injector().get('cc') and $transition$.injector().get('cc') it seems to only be able to get the variables of the next state.

In short: Is there a way to get the values resolved when entering the state in the corresponding onExit function?

Angular 1.5.5, angular-ui-router@1.0.0-beta.3

@christopherthielen
Contributor

I believe that's intended to still work in 1.0. I'll take a look

@christopherthielen christopherthielen added this to the 1.0.0-final milestone Oct 12, 2016
@christopherthielen christopherthielen added a commit to ui-router/core that closed this issue Nov 2, 2016
@christopherthielen christopherthielen feat(Transition): Support treechange paths in API for Resolve+transition
- Allow resolve data to be retrieved for arbitrary tree change paths, including `to` and `from`, but default to the `to` path
docs(Transition): add docs and mark some as @internalapi

Closes angular-ui/ui-router#3081
beedc82
@christopherthielen christopherthielen added a commit that referenced this issue Nov 2, 2016
@christopherthielen christopherthielen fix(onExit): inject resolve values using the "from path"
fix(onExit): inject the current transition as `$transition$`

Closes #3081
c91b65a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment