mardi 1 décembre 2015

How to pass model data in a each loop in template to controller without using action in ember

This is the template:

{{#each user in inquiry.users}}
    <li>
       {{user.email}}
       <div class="pretty small danger btn icon-right entypo icon-cancel" {{action 'removeUser' user}}><a href="#">remove</a></div>
    </li>
{{/each}}

This is the controller: App.ManageUsersModalController = Ember.Controller.extend({ needs: ['inquiry'], inquiry: Ember.computed.alias('controllers.inquiry.model'),

createdBy: function() {
    return this.get('inquiry.created_by').substring(4);
}.property('inquiry'),
username: function(){
    return this.get('user.username');
}.property(),

//indented

});

I want to check whether the user is primary or not by compare the inquiry.created_by and user.username. I can get properties in the inquiry model. But can't do the same for user model. Can someone tell me how to pass the child data while do a loop in the template to controller without using action helper. As I don't need a click on the page to show whether the user is primary or not.




Aucun commentaire:

Enregistrer un commentaire