I've a list of items. They are objects held in itemArray. When you touch one you it fires ng-click="openEditor(item)". Like this:
<ion-list>
<ion-item ng-repeat="item in ItemArray" class="item item-avatar" ng-click="openEditor(item)">
<img ng-src="{{iconMap[item.type]}}">
<h2>{{item.dateString}}</h2><span>{{item.startTimeString}}</span>
<p>ASA {{item.priority}}: {{item.itemType}}</p>
</ion-item>
</ion-list>
Then this happens:
$scope.openEditor =function(item){
$scope.currentItem = item;
$scope.modal.show();
}
and in the modal I have
<select ng-model="currentItem.priority">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
It shows the correct priority in the dropdown (I've tested it with a lot of the items).
The problem is - I cannot change it! If I try I can't alter the option in the dropdown.
I get this error:
TypeError: Cannot assign to read only property 'priority' of #<Object>
Why is this happening? I want to change the priority and then save it back into the itemArray and SQL DB.
Sounds like the object you're trying to change is read-only. You need to investigate why this is, but you could make a copy of the object with
$scope.openEditor =function(item){
$scope.currentItem = angular.copy(item);
$scope.modal.show();
}