# This.set("prop", value) doesn't trigger a view change - but the prop does change

**URL:** <https://discuss.emberjs.com/t/this-set-prop-value-doesnt-trigger-a-view-change-but-the-prop-does-change/11840>\
**Category:** Uncategorized\
**Created:** [October 29, 2016, 6:31pm UTC](https://discuss.emberjs.com/t/this-set-prop-value-doesnt-trigger-a-view-change-but-the-prop-does-change/11840 "2016-10-29T18:31:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![frsechet](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/frsechet/32/12517_2.png) [@frsechet](https://discuss.emberjs.com/u/frsechet)\
**Post date:** [October 29, 2016, 6:31pm UTC](https://discuss.emberjs.com/t/this-set-prop-value-doesnt-trigger-a-view-change-but-the-prop-does-change/11840/1 "2016-10-29T18:31:18Z")

</div>

Hi there,

I have the following logic in a component:

```auto
import Ember from 'ember';

export default Ember.Component.extend({
  selectedCats: [],
  actions: {
    selectCategory: function(category) {
      var myCats = this.get('selectedCats');
      myCats.push(category.id);
      this.set('selectedCats', myCats);
    }
  }
});

```

and the following view:

```auto
{{#each selectedCats as |cat|}}
{{cat}}
{{/each}}

```

`selectCategory()` is triggered when I click on something below. **However, the view is not updated then.** To get my view to update, I have to change `selectCategory()` to the following, which is functionnally identical but recreates a whole new array somewhere else with the same content:

```auto
  selectCategory: function(category) {
      var myCats = [];
      this.get('selectedCats').forEach(function(existingCat) {
        myCats.push(existingCat);
      });
      myCats.push(category.id);
      this.set('selectedCats', myCats);
    }

```

The only difference is that in one case, myCats is an Ember Array, in the other case it’s just a regular array. In both cases, if I console.log `selectedCats` at the end, I get the exact same result. Only the view does not get updated in the first case.

I would really like to know/understand why… 🙂

Thanks! François

---

<div class="post-metadata">

**Author:** ![alexspeller](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/alexspeller/32/14812_2.png) [@alexspeller](https://discuss.emberjs.com/u/alexspeller)\
**Post date:** [October 30, 2016, 5:12pm UTC](https://discuss.emberjs.com/t/this-set-prop-value-doesnt-trigger-a-view-change-but-the-prop-does-change/11840/2 "2016-10-30T17:12:24Z")

</div>

You are using `push`. That wont’ work in ember. You have to use one of ember’s array methods, like `pushObject`.

your function can be replaced with:

```auto
selectCategory(category) {
  this.get('selectedCats').pushObject(category.id);
}

```
