0

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

1
  • Please post code that shows how you are using ng-repeat and other things to show data in modal. Commented May 13, 2015 at 13:00

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.