0
votes

I want to observe a nested property. I have the following Ember Array:

specifications: [
  {
    title: "specification name",
    filters: [
      {
        title: "example"
        checked: false
      },
      {
        title: "example 2",
        checked: true
      }
    ]
  },
  ...
]   

I want to create a computed property:

activeFilters: (->
  Ember.computed.filterBy('[email protected]', 'checked', true),
).property('[email protected]')

The active filters property is not working, I tried several combinations of property methods, but none worked.

Is the property I am trying to create actually possible?

1
Do you mean specifications.filters.@each? - user663031
I noticed that you never accept answers. Consider closing some of your questions. - givanse
I will do that right now. - Hoetmaaiers

1 Answers

0
votes

Yes, it is possible. The thing is that for it to work you can't use a JavaScript array, you need an Ember.ArrayProxy and then you can access its special properties: http://emberjs.com/api/classes/Ember.ArrayProxy.html

specifications: Ember.ArrayProxy.create({
  content: [
    {
      title: "specification name",
    },
  ]
});

So, you'll have something like:

oneSpecChangedCheck: function() {
  // don't know which, but someone changed
  var s = this.get('specs');
  // loop and process
  return s;
}.property('[email protected]'),

http://emberjs.jsbin.com/zohuzo/2/edit?html,js,console,output