Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.0-alpha.1: Cannot read property 'resolveContext' of undefined #2657

Closed
garycourt opened this issue Mar 30, 2016 · 2 comments
Closed

1.0.0-alpha.1: Cannot read property 'resolveContext' of undefined #2657

garycourt opened this issue Mar 30, 2016 · 2 comments

Comments

@garycourt
Copy link

I'm attempting to upgrade ui-router to angular-ui-router#1.0.0-alpha.1 with angular#1.4.7. Some of our links are throwing errors at the following line:

var resolveCtx = common_1.find($transition$.treeChanges().to, hof_1.propEq('state', vc.viewDecl.$context)).resolveContext;
TypeError: Cannot read property 'resolveContext' of undefined

Best I can tell, routes that have a resolve option to them ($stateProvider.state('foo',{resolve:{/*...*/}})) seem to throw this.

Any ideas why common_1.find would return undefined when this route used to work in angular-ui-router#0.2.17?

@christopherthielen christopherthielen changed the title Cannot read property 'resolveContext' of undefined 1.0.0-alpha.1: Cannot read property 'resolveContext' of undefined Mar 30, 2016
@christopherthielen christopherthielen added this to the 1.0.0-alpha.2 milestone Mar 30, 2016
@christopherthielen
Copy link
Contributor

That code is fetching all the locals (resolve data) for a view (controller)

As far as I can tell, we couldn't find the right object in the "to path" (which is the path of nested states from the root state down to the transition's target state).

This could be caused by a number of things. Can you drop a breakpoint there (in Chrome, use the "pause on exceptions" feature) and report back what is the value of:

  • vc.viewDecl
  • vc.viewDecl.$context.name
  • $transition$.treeChanges().to.map(function(node) { return node.state.name; })
  • $transition$.treeChanges().to.map(function(node) { return node.resolveContext; })
  • I'd also like to see the state definition which is failing.

If I can reproduce this, I'll get this fixed up ASAP and put into alpha.2

@garycourt
Copy link
Author

As requested:

//vs.viewDecl
{
$context:exports.extend.exports.extend
$name:"menu@main.shop"
$type:"ng1"
$uiViewContextAnchor:"main.shop"
$uiViewName:"menu"
controller:"ShopMenuController"
resolveAs:"$resolve"
templateUrl:"shopMenu.html"
}

//vc.viewDecl.$context.name
"main.shop.collection.category"

//$transition$.treeChanges().to.map(function(node) { return node.state.name; })
["", "main", "main.shop", "main.shop.category"]

//$transition$.treeChanges().to.map(function(node) { return node.resolveContext; })
[ResolveContext, ResolveContext, ResolveContext, ResolveContext]

If you still need to see the state definitions, let me know and I'll send it as a PM to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants