Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ember.computed.filter crashes obsevring an array #9554

Closed
estshy opened this issue Nov 12, 2014 · 1 comment
Closed

Ember.computed.filter crashes obsevring an array #9554

estshy opened this issue Nov 12, 2014 · 1 comment

Comments

@estshy
Copy link

estshy commented Nov 12, 2014

Let's start with working demo: http://jsbin.com/monanipiwe/1/

App = Ember.Application.create();

var first = Ember.Object.create({
  name: 'first',
  id: 1
});

var second = Ember.Object.create({
  name: 'second',
  id: 2
});

App.ApplicationRoute = Ember.Route.extend({
  model: function() {
    return [first, second];
  }
});

App.ApplicationController = Ember.ArrayController.extend({
  showOnlyWithIds: [1,2,3,4,5,6],
  filteredModel: Ember.computed.filter('@this', function(item) {
    return item.get('name');
  }).property('@this')
});

Inside controller I have some ids that are observed by function line below. I am going to use it to filter model.

App.ApplicationController = Ember.ArrayController.extend({
  showOnlyWithIds: [1,2,3,4,5,6],
  filteredModel: Ember.computed.filter('@this', function(item) {
    return item.get('name');
  }).property('@this', 'showOnlyWithIds')
}); 

But wait... I can't.

TypeError: item.get is not a function

I don't understand why but each item of showOnlyWithIds is passed as parameter to callback. Why?

@estshy estshy changed the title Ember.computed.filter crashes obsevring array Ember.computed.filter crashes obsevring an array Nov 12, 2014
@wagenet
Copy link
Member

wagenet commented Nov 12, 2014

Grouping with #9462

@wagenet wagenet closed this as completed Nov 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants