vyshnavi vyshnavi - 5 months ago 14
AngularJS Question

How to update in front end?

how to do operations in angular js



Okay from what I gather this is what you want:

In HTML inside of ng-repeat:

<input type="text" ng-model="phone.phoneNumber" />

// at this point when the user types their new phone number in the "phone" object has already been updated (via two-way data binding). Then if you want to save to database you can send to your service via the controller method $scope.updatePhone with the button.

<button ng-click="updatePhone(phone)">Update</button>

Then in the controller:

$scope.updatePhone = function (phone) {
    console.log("this is the updated phone: ",phone);
    console.log("this is the updated phones array: ",$scope.phones);
    // you should see that the phone number has been updated in scope.


    // this service call should be a post to the server, not a return object as the object has already been updated.


Hope this helps