EasyCo
EasyCo

Reputation: 2036

Filter through relationships

I've got the following component:

export default Ember.Component.extend({
  frontLayers: function() {
    return this.get( 'layerColours' ).filterBy( 'layer.aspect.angle', 'Front' );
  }.property( '[email protected]' )
});

Where layerColours has one layer and it has one aspect with an angle property.

The problem is the filtering doesn't work. Debugging the return value in the console just gives me [_super: function, nextObject: function, firstObject: Object, lastObject: Object, contains: function...]

If I remove the filterBy I get the layerColours no prob.

Upvotes: 1

Views: 32

Answers (1)

EasyCo
EasyCo

Reputation: 2036

So I stumbled on this: http://discuss.emberjs.com/t/ember-js-ember-data-filtering-in-controller-not-resolving-the-belongsto-relationship-whereas-template-does/4711/4

So ended up changing frontLayers to:

  frontLayers: Ember.computed.filterBy('coordinate.layerColours', 'layer.aspect.angle', 'Front')

and all started working as it should.

Upvotes: 1

Related Questions