Question

I have got this model, where site is an array of sites:

App.Topology = DS.Model.extend({
name: DS.attr('string'),
site: DS.attr()
});

And I am trying to retrieve this array in a computed property:

return this.filterBy('name', this.get('selectedName')).get('site');

The filterBy functiion returns correcty:

<App.Topology:ember411:1>

But with the get('site') it´s undefined.

Was it helpful?

Solution

Are you sure filterBy doesn't return an array? so something like [<App.Topology:ember411:1>]

Because that's what it's supposed to do, see http://emberjs.com/api/classes/Ember.Enumerable.html#method_filterBy. If it does return an array you can use the firstObject property:

return this.filterBy('name', this.get('selectedName')).get('firstObject').get('site');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top