Reputation: 459
I have a json array with objects. Each object has bunch of key and values. Using ng-repeat
to shown the object's in my html page. If i click edit for the particular object, an object will toggle on bootstrap
modal. If changes made in the modal window, its directly affects the json
object and instant changes should occur in UI. so i using a angular.copy
to take an duplicate object and shown in the modal window. I want to do, if i click update button means within the modal dialog, splice the json object and insert the duplicated
json object into the array within the same index. How can i do it. Here sample code
$scope.array = [{"ItemId":"20113",
"ItemModel":"C2",
"ItemName":"Nokia", .....},
{....},
{....},
{....}, ......]
I want splice
index 2 in the array and insert an new object in the array as the same index of 2
Upvotes: 0
Views: 1479
Reputation: 11388
Why are you using angular.copy?
If you were passing the object you want to edit, you wouldn't need to refres it afterwards. (sorry I misread that you needed an update button)
Although, to answer your question, your solution would be to replace the object by the new one :
$scope.array[index] = modifiedObject;
Upvotes: 1