1
votes

After updating ember-cli to 0.1.5 i am getting a new error.

 var radioList = this.get('radioList').slice(0);
        radioList.forEach(function (item) {
            item.isSelected = false;
        }); 
         this.set('radioList',radioList);

radioList property is being observed. However in the above scenario it is being sliced which is basically creating a new copy of it. How come even then i am getting the below error?

Uncaught Error: Assertion Failed: You must use Ember.set() to set the isSelected property (of [object Object]) to false.

1

1 Answers

1
votes

However in the above scenario it is being sliced which is basically creating a new copy of it.

You are creating a copy of array by calling slice method, but it's not a 'deep copy' - objects in both original and copy arrays are the same. You can check it in Chrome/FF console:

var array = [{ field: 1 }];
var slicedCopy = array.slice(0);
slicedCopy[0] === array[0]; // => true

I hadn't explore ember's version of slice very deep, but there is a possibility that even deep copy in your case will lead to the same result. So, just use Ember.set to set values in ember app. :)