dimanche 26 juillet 2015

Returning 1 object/record from my model in Ember

In a test app I running, I have fixture data for employees with name, department, etc. Currently, my model contains all of the employees, and I am able to make an employee list. However, I want to make a side component that lists the information of 1 specific employee (i.e. the one clicked, as a tooltip). How can I pass just 1 employee to my component?

I have an action that updates a property whenever someone clicks a name. I thought to do a computed property to query the model based on that name, but I am not sure how to filter my model to return just the one employee.

actions: {
  updateProfile(person) {
    set(this, 'profile', person);
  }
}

And my computed property:

currentProfile: computed('profile', function(){
  return this.model.find('person', {'name': get(this, 'profile')});
}),

Is there a simple way to return just the 1 object I want from my model?




Aucun commentaire:

Enregistrer un commentaire