angular-ui / ui-router

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

transition hook injects from wrong state #3546

Closed i23591326 closed 6 years ago

i23591326 commented 6 years ago

This is a:

My version of UI-Router is: 1.0.5

Bug Report

Current Behavior:

I have two states: people and people.person.

Each state has different resolve with same token 'person'. For people state resolve just returns 123. people state has transition hook (onEnter: function(person){console.log(person)}) with dependency 'person'. When i load app and go https://run.plnkr.co/YQSDfiSkqAmmxVd9/#/people/ i see in console: 123

When i load app and go directly https://run.plnkr.co/fqaJMXD8mb7cMjxI/#/people/293 i see in console: undefined

it seems onEnter hook trying to inject resolve from wrong (child or last) state when child state contains resolve with the same token

Expected Behavior:

transition hook can inject resolves only from current or parent states

Link to Plunker that reproduces the issue:

https://plnkr.co/edit/2Jk549su23F789BNTnb1?p=preview

by the way dependency injection inside resolve "people: function(PeopleService, person) {console.log(person))...}" works perfectly fine no matter which state i go first when app is loaded

christopherthielen commented 6 years ago

Thanks for the bug report. This is definitely a bug.