I have an each loop which outputs a table of data. Each row includes created_date, title, publisher and category. In order to use sortProperties in the relevant controller (To sort the posts by created_date), I have set it to loop over the controller:
<button {{action 'reverseOrder' 'created_date'}}>Reverse Date Order</button>
{{#each controller as |post|}}
...
{{/each}}
I would also like to have buttons which filter this list by other columns (For example publisher). I've looked at this jsbin example, which passes filteredContent to the each helper in the template, and then uses that in the controller to do the filtering:
{{#each filteredContent}}
...
{{/each}}
App.IndexController = Em.ArrayController.extend({
filteredContent: [],
actions: {
filterByPublisher: function(filterFn) {
this.set('filteredContent', this.get('model').filter(filterFn));
}
}
});
What is the correct way to pass the filteredContent to the each helper which already specifies the controller?
I've tried various things-
{{#each controller as |post| filteredContent}}
{{#each filteredContent controller as |post|}}
However I get errors like the following:
Uncaught Error: Assertion Failed: If you pass more than one argument to the each helper, it must be in the form {{#each foo in bar}}
Aucun commentaire:
Enregistrer un commentaire