# Ember update property on the changes in array

**URL:** https://discuss.emberjs.com/t/ember-update-property-on-the-changes-in-array/5939
**Category:** Ember Data
**Created:** [July 21, 2014, 7:41pm UTC](https://discuss.emberjs.com/t/ember-update-property-on-the-changes-in-array/5939 "2014-07-21T19:41:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![swatijadhav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/swatijadhav/32/15964_2.png) [@swatijadhav](https://discuss.emberjs.com/u/swatijadhav)
#### Post date: [July 21, 2014, 7:41pm UTC](https://discuss.emberjs.com/t/ember-update-property-on-the-changes-in-array/5939/1 "2014-07-21T19:41:11Z")

</div>

I have following in my controller, and facing issue while updating property with array change… import Ember from ‘ember’;

> export default Ember.Controller.extend({

> imageIds: Object.keys(JSON.parse(localStorage.image\_ids || “{}”)),  
> // [‘gnffffffffjdf’, ‘hzfyfsidfulknm’, ‘euriekjhfkejh’]
> 
> previewImageId: function() { return this.imageIds.get(‘firstObject’);  
> }.property(‘imageIds.’),
> 
> noImage: function() { return this.get(‘imageIds.length’) === 0; }.property(‘imageIds.@each’),
> 
> actions: { addDetails: function() { this.transitionToRoute(‘items.add\_item’); },
> 
> ```
> removeImage: function(image_id) {
> var uploaded = JSON.parse(localStorage.image_ids || "{}");
> delete uploaded[image_id]
> localStorage.image_ids = JSON.stringify(uploaded);
> this.get("imageIds").removeObject(image_id);
> // this.set("imageIds", Object.keys(JSON.parse(localStorage.image_ids || "{}")));
> },
> 
> updatePreview: function(image_id){
> this.set("previewImageId", image_id);
> var uploaded = JSON.parse(localStorage.image_ids || "{}");
> uploaded[image_id] = image_id;
> localStorage.image_ids = JSON.stringify(uploaded);
> // this.set("imageIds", Object.keys(JSON.parse(localStorage.image_ids)));
> this.get("imageIds").pushObject(image_id);
> } }
> 
> ```
> 
> });

Whenever there is any change in the imageIds array, previewImageId should be updated. tried using pushObject, removeObject, .get and .set options. But still no luck

Can anyone pls help me?

---

<div class="post-metadata">

### Author: ![maxn](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@maxn](https://discuss.emberjs.com/u/maxn)
#### Post date: [July 22, 2014, 6:44am UTC](https://discuss.emberjs.com/t/ember-update-property-on-the-changes-in-array/5939/2 "2014-07-22T06:44:05Z")

</div>

> [@swatijadhav](#):
>
> updatePreview: function(image\_id) {  
> this.set(“previewImageId”, image\_id);  
> …  
> }

You are overriding your computed property right there. You could try making your computed property a setter ([Ember.js Docs Guide](http://emberjs.com/guides/object-model/computed-properties/#toc_setting-computed-properties)) or use an observer instead.

Hope that helps.

---

<div class="post-metadata">

### Author: ![swatijadhav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/swatijadhav/32/15964_2.png) [@swatijadhav](https://discuss.emberjs.com/u/swatijadhav)
#### Post date: [July 22, 2014, 6:03pm UTC](https://discuss.emberjs.com/t/ember-update-property-on-the-changes-in-array/5939/3 "2014-07-22T18:03:11Z")

</div>

yes you are correct… updated now… working… thanks 👍
