Eliot
Eliot

Reputation: 137

Cannot access to parent model from child view

I have a problem with my emberjs view. I cannot access to the model defined in the parent view. I have tested with view.parentView.model and this not working

Here is my code :

<div class="allowed_name">{{model.allowed_email_domain}}</div><!-- working -->
{{#each view.content}}
  <h1>{{model.allowed_email_domain}}</h1> <!-- not working -->
{{/each}}

Thank's

Upvotes: 2

Views: 60

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Ignoring the fact that you are using the view and probably shouldn't be, it's because you've changed the context inside the each loop.

Depending on the version of handlebars/htmlbars you are using

<div class="allowed_name">{{model.allowed_email_domain}}</div><!-- working -->
{{#each view.content as |item|}}
  <h1>{{model.allowed_email_domain}}</h1> <!-- working -->
{{/each}}


<div class="allowed_name">{{model.allowed_email_domain}}</div><!-- working -->
{{#each item in view.content}}
  <h1>{{model.allowed_email_domain}}</h1> <!-- working -->
{{/each}}

Upvotes: 2

Related Questions