ajax - How to refresh a table after a successfull Post using $evalAsync -


I need to update my table after a successful post without reloading the page. Works, but I can not get it to work with Post Works

  // Update job $ scope.updateJob = function (job) {jobFactory.updateJob (jobs). Civet (success callback) .error (errorCallback); Console.log (work); $ Scope.cancelEditJobModal (); $ Scope $ EvalAsync (function () {$ scope.job;}); };   

does not work

  // Job after new job $ scope.submitJob = function () {var data = {Job ID: $ scope. NewItems JobId, JobNumber: $ scope.newItems.JobNumber, JobName: $ scope.newItems.JobName, Job Description: $ scope.newItems.JobDescription,} $ http.post ('/ api / apiJob / PostNewJob', data). Function (data, position, header) {console.log (data); $ scope.cancelNewJobModal (); $ scope. $ EvalAsync (function () {$ scope.data;}}}}}};  < It is not clear what you want to achieve.  
I see from your code, that you are posting a job to save it. First of all, the server is saving correctly, and What is it (like data in success handler)? After that, if you have an array of functions in your scope, then you have to manually push the new item into the array.

To indicate, here is your code snippet, an archive modified to push the new job: // Post a new job $ scope.submitJob = function () {var data = {JOBID: $ scope.newItems.JobId, JobNumber: $ scope.newItems.JobNumber, JobName: $ scope.newItems.JobName, Job Description: $ scope.newItems.JobD Escription;}; $ Http.post ('/ api / apiJob / PostNewJob', data). Svitt (function (data, position, header) {// Clone New Eatam, New Eatam is a reference var tmpNewItem = angular.copy ($ scope.newItem ); // It assumes that you have $ scope.jobslist as your archive // ​​Now we can add new items to the clone for the collection $ scope.jobslist.push (tmpNewItem) // newItem reset , This angular.copy ({}, $ scope.newItem); $ scope.cancelNewJobModal ();}); };

I set up a quick example to push the new item (without $ http)

In addition, your code seems to work in the sample update , Because two-way data binding is changing instantly to angular values ​​and does not depend on the server to save correctly.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -