ember.js - Fetch search result from controller -


 app.exam = ds.model.extend({  examtype: attr('string'),  examdate: attr('date'),  gradetext: attr('string'),  coursename: attr('string'),  coursename__startswith: attr('string'),  typename: attr('string'),  numberof: attr('number'),  grade: attr('number'), }); 

here model want access controller. filter model using this

app.examcontroller = ember.controller.extend({   // initial value of `search` property      search: ''       ,query: function() {      // current value of text field      var querycoursename = this.get('searchcoursename');      this.set('searchresult',app.exam.find({coursename: querycoursename})     }   }); 

is correct way store results of app.exam.find()? if how access searchresult property controller , iterate through values?

depending on want do, if set property searchresult on examcontroller doing this:

... this.set('searchresult', app.exam.find({coursename: querycoursename})); ... 

then later able, in controller(s) use needs directive gain access examcontroller:

app.anothercontroller = ember.controller.extend({   needs: ['exam'],   exambinding: 'controllers.exam',   ...   myfunction: function() {     this.get('exam.searchresult') // here values   } }); 

worth noting here suffix binding in exambinding tells ember setup binding between 2 properties, more info check out api doc's ember.binding

hope helps


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -