Skip to content

Instantly share code, notes, and snippets.

@courtneyphillips
Last active March 11, 2016 17:59
Show Gist options
  • Save courtneyphillips/f48abb4ee2c2f03053bc to your computer and use it in GitHub Desktop.
Save courtneyphillips/f48abb4ee2c2f03053bc to your computer and use it in GitHub Desktop.
Using .intersect functionality of Ember Computed Properties in component
import Ember from 'ember';
export default Ember.Component.extend({
selectedSkills: Ember.inject.service(), // <-- service containing an array of objects.
selected: Ember.computed.alias('selectedSkills.skills'), // <-- giving 'selected' nickname to this array of objects within service.
skillsInCommon: Ember.computed.intersect('selected', 'project.skills'), // <-- returning only the objects present in both the service's array and in 'project.skills' (current model where this component is being called?)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment