I have a model request that has an attribute user_id. That user_id has a relationship to the id of the model user.
I want to display each user in a template, and below each user a list of all requests that have been assigned to that user. The model should hopefully be request, as I have other templates that iterate through request and it would be great to reuse that model if possible.
In hbs it would look like this:
#outside.hbs
<div class="row text-left">
<div class="col-md-2">
</div>
</div>
#requests-component.hbs
<h4 class="request-heading"></h4>
...
Now, inside the component, how do I filter the requests to iterate over each specific user_id and create a new iteration if it's another user_id?
I've tried with the following in the component:
request: Ember.computed('model.@each.userId', function () {
return this.get('sortedRequests').filterBy('userId', this.get('userId'));
//imagine this.get('userId') = [1, 2, 3, 4]
})
How can I create a new request object that filtersBy each user_id, so that I have a list with lets say 10 Users on that template, where each is assigned the respective Requests, if user_id matches the user.id?
Thanks a lot!
Aucun commentaire:
Enregistrer un commentaire