TypeError: Cannot assign to read only property 'x' of #



I have a little problem and i don’t know how to solve the error.

What i want to do

I fetch data from Database (sqlite plugin/websql) and bind it to a form, so i can change it and save again to the db.
Somehow the object is now readonly and throws TypeError: Cannot assign to read only property 'x' of #<Object>

Here you can see the problem (its nearly 1:1 of my code)

Error in Console!


Found the problem but im not sure why :slight_smile:

I have to copy the object in the fetch method with angular.copy and then returning it.
And then its works.

  1. init your scope object: $scope.person = {} to work with a defined object
  2. avoid using person.form if you want to store only persons in the object. use personForm instead
  3. maybe you get a real sql-object from your connector -> thats why it is readonly, angular.copy will make a shallow copy of this object and you have no references to the old db-object (if you object is not deep nested :wink: )


thank you for your advice!

would make sense if its a db-object, just strange i saw only a object without any infos what it is :smiley: