# Computed properties on an itemController when using a filtered model

**URL:** <https://discuss.emberjs.com/t/computed-properties-on-an-itemcontroller-when-using-a-filtered-model/5545>\
**Category:** Uncategorized\
**Created:** [June 5, 2014, 5:06pm UTC](https://discuss.emberjs.com/t/computed-properties-on-an-itemcontroller-when-using-a-filtered-model/5545 "2014-06-05T17:06:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike\_roosa](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mike_roosa/32/15652_2.png) [@mike\_roosa](https://discuss.emberjs.com/u/mike_roosa)\
**Post date:** [June 5, 2014, 5:06pm UTC](https://discuss.emberjs.com/t/computed-properties-on-an-itemcontroller-when-using-a-filtered-model/5545/1 "2014-06-05T17:06:32Z")

</div>

Can someone help me understand why my computed property fullName isn’t working with the filteredPeople list?

As you can see on this jsbin, it works fine when I use the computed on the model.

[http://emberjs.jsbin.com/gojilofa/2/edit](http://emberjs.jsbin.com/gojilofa/2/edit)

---

<div class="post-metadata">

**Author:** ![Spencer\_Price](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/spencer_price/32/14878_2.png) [@Spencer\_Price](https://discuss.emberjs.com/u/Spencer_Price)\
**Post date:** [June 5, 2014, 5:19pm UTC](https://discuss.emberjs.com/t/computed-properties-on-an-itemcontroller-when-using-a-filtered-model/5545/2 "2014-06-05T17:19:18Z")

</div>

Since you’re filtering against the `model` array, those are the raw objects not wrapped in your `itemController`.

Changing your computed filter to `...Ember.computed.filter('@this', function...` should do the trick.

---

<div class="post-metadata">

**Author:** ![mike\_roosa](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mike_roosa/32/15652_2.png) [@mike\_roosa](https://discuss.emberjs.com/u/mike_roosa)\
**Post date:** [June 5, 2014, 5:22pm UTC](https://discuss.emberjs.com/t/computed-properties-on-an-itemcontroller-when-using-a-filtered-model/5545/3 "2014-06-05T17:22:43Z")

</div>

using @this didn’t seem to help

---

<div class="post-metadata">

**Author:** ![Spencer\_Price](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/spencer_price/32/14878_2.png) [@Spencer\_Price](https://discuss.emberjs.com/u/Spencer_Price)\
**Post date:** [June 5, 2014, 6:09pm UTC](https://discuss.emberjs.com/t/computed-properties-on-an-itemcontroller-when-using-a-filtered-model/5545/4 "2014-06-05T18:09:27Z")

</div>

Ah, I didn’t actually test your code…my apologies. The issue I described was indeed part of the problem.

The second issue is related to how you’re invalidating the computed property…by calling `.property` on it. I’ve never done this…so, not sure wether that’s considered appropriate (or is expected to work, for that matter).

If you really wanted that behavior where other non-array properties invalidate the entire reduced array, you could write your own [Reduce Computed Property](http://emberjs.com/api/classes/Ember.html#method_reduceComputed).

That being said, I’ve handled this in a different way without having to create a new Reduce Computed property that seems to work well…try something like this:

```
App.PersonController = Ember.ObjectController.extend({
  fullName: function() {
    return this.get('firstName') + ' ' + this.get('lastName');
  }.property('firstName','lastName'),

  matchesFilter: function() {
    var searchFilter = this.get('parentController.searchFilter');
    var regex = new RegExp(searchFilter, 'i');
    return this.get('firstName').match(regex);
  }.property('parentController.searchFilter')
});

App.IndexController = Ember.ArrayController.extend({
  itemController: 'person',
  searchFilter: 'kris',
  filteredPeople: Em.computed.filterBy('@this', 'matchesFilter')
});

```

---

<div class="post-metadata">

**Author:** ![mike\_roosa](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mike_roosa/32/15652_2.png) [@mike\_roosa](https://discuss.emberjs.com/u/mike_roosa)\
**Post date:** [June 6, 2014, 3:00pm UTC](https://discuss.emberjs.com/t/computed-properties-on-an-itemcontroller-when-using-a-filtered-model/5545/5 "2014-06-06T15:00:53Z")

</div>

After a lot of pulling out of my hair this is now working. I was confused because the jsbin was working but my app wasn’t. Apparently it was fixed with canary, because I installed canary and it’s working fine.
