angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.53k stars 3k forks source link

State transition occurring before resolving dependency #2048

Closed LeonanCarvalho closed 8 years ago

LeonanCarvalho commented 9 years ago

I think i'm getting a related issue than #2047, but the scenarios is different and I'm using a 3th-party plugin to resolve my dependencies.

The problem is the state transition is occurring before resolve dependencies. For this reason the controller isn't loaded on mudule.

.state('app.config.params', {
                    url: '/params',
                    data: {
                        modulo: '00.000.00',
                        title: 'Params Config',
                        access: access.user
                    },
                    views: {
                        "content@app": {
                            templateUrl: 'app/modules/_admin/config/views/params/index.html',
                            controller: 'paramsController',
                            resolve: {
//At version 0.2.14 its works fine, in 0.2.15 does not.
                                deps: $couchPotatoProvider.resolveDependencies([
                                    'modules/_admin/config/controllers/paramsController'
                                ])
                            }
                        }
                    }
                })

$couchPotato is a component that Lazy-Load and Register Components in AngularJS Applications

I'm using angular 1.4.1

eddiemonge commented 9 years ago

This could potentially be a bug but I'm not sure if it should be solved here or at $couchPotato. It would seem here since it works in one version and not the next.

LeonanCarvalho commented 9 years ago

$couchPotato returns a function, The goal should resolve this function, isn't it?

I think not, because the same version of couchPotato works with 0.2.14, something has changed to 0.2.15?

cah-ricksuggs commented 9 years ago

I've encountered a similar issue after upgrading to version 0.2.15

When initially transitioning to a route, the dependencies are resolved and controller is executed. However when revisiting the same route after navigating away, the controller is executed, then dependencies are resolved, and the state transition finally occurs.

It appears to be a regression because after downgrading to version 0.2.14 the issue no longer occurs.

christopherthielen commented 8 years ago

Move the resolve out of the view, and into the state definition.

resolve: {} is a state-level thing, not a view-level thing.

christopherthielen commented 8 years ago

I believe the original reported issue is "not a bug" since resolve: {} is not supported on views; it is only supported on states definitions.

Please open a new issue if there is something else going on here, as @cah-ricksuggs suggests.