1

I was updating my view by refreshing the page. I know that there is a better way. Can someone show me how to update the view data without refreshing the page:

myApp.service("deleteService", function ($http) {
    this.removeRow = function (recId, compName, custName, docName) {
         $http.post('DeleteRecord', { settingID: recId,companyName: compName,customerName: custName, documentName: docName } )
         .success(function (data, status, headers, config) {
              window.location.reload();
         })
         .error(function (data, status, header, config) {
         });
    }
});
3
  • call the same function which you use to get view data in the first place, inside delete success Commented Jun 21, 2016 at 15:13
  • 1
    What do you mean by updating your view? Updating the model bindings? In your success event, you can set the bindings in your model and the view will reflect those changes. Commented Jun 21, 2016 at 15:20
  • Thank you .Could you please show me how to do that. Commented Jun 21, 2016 at 15:21

1 Answer 1

1

Without seeing the rest of your code it is hard to be able to give you an exact answer, but I'm going to assume you have a service to get your data.

Approach 1) You can inject your "getService"? into this service and access the function you use to retrieve the data initially.

Approach 2) Instead of having a seperate service for each CRUD function, you can have a CRUD service that will manage the data manipulation, this way you can just call the "get" function without injecting a seperate service.

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.