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

Nested Each loses parent context variables #30

Closed
ghost opened this issue Feb 27, 2018 · 3 comments
Closed

Nested Each loses parent context variables #30

ghost opened this issue Feb 27, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 27, 2018

Hi
example code:

@each( item in items )
<td> {{ item.name }} </td>

    @each( plan in plans )
      {{   renderPlan( item.plans, plan.id ) }}
     @endeach

@endeach

Where renderPlan is registered View.global via service provider in Adonis like

renderPlan( plans, idToFind){
// here plans is always empty string  
...
}

I've set debugger like

@each( item in items )
<td> {{ item.name }} </td>
@debugger

    @each( plan in plans )
    @debugger
           {{   renderPlan( item.plans, plan.id ) }}
     @endeach

@endeach

on the first debugger at runtime
this this.context.resolve('item.plans') returns correct value from object
the second debugger stop, however, returns "" ( right after the newFrame() call )

@thetutlage
Copy link
Member

You can access it as $parent.item.plans

@ghost
Copy link
Author

ghost commented Feb 28, 2018

@thetutlage Thanks! this could be in the documentation, I'm closing this as it's working fine with $parent accessor

@techtuxbr
Copy link

For me it's not working, seems like the $parent is undefined.

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

No branches or pull requests

2 participants