dimanche 27 septembre 2015

Rendering the results of controller actions in templates with Ember 1.13

First off, very new to Ember and especially the changes made to the role of controllers.

In my ember-cli 1.13.8 application, I have a controller action that finds items that were filtered through a user search. The problem is that the result of this search is never rendered on the template.

Controller:

import Ember from 'ember';

export default Ember.Controller.extend({

 actions: {
   query: '',
   searchQuestions: function() {
     var filter = this.get('query');
     return this.get('model').filter(function(item) {
       return item.get('title').indexOf(query) !== -1;
     });
   }
 }
});

Template:

{{#each searchQuestions as |item|}}
  <p>{{item}}</p>
{{/each}}

My understanding is that searchQuestions should be available to the template. The action is correctly called and will run through the model that is returned from the route. I've console.logged out the method and it will intermittently print out -1 or 0 so it finds the matches. It just will not update in the template.

I have consulted the guides: http://ift.tt/1P0BZTJ as well as tried using {{outlet}} based up this question: Ember route not displaying template content.

If you can even recommend a good article for conceptually understanding the flow of an Ember application I'd be very appreciative.




Aucun commentaire:

Enregistrer un commentaire