Greko2009
Greko2009

Reputation: 563

AngularJS detect any kind of change in data and send a single update request

Suppose we have the following data:

 [
 {
   "id": "1",
   "name": "John"
 } , 
 {
   "id": "2",
   "name": "Jane"
 }
 ]

They are displayed in an editable table, which allows user to add/edit/delete rows using appropriate buttons.

The requirement is to replicate Powerbuilder's Datawindow functionality:

When the user is done editing data, he should be able to press a single "Update" button, which is supposed to detect which rows were changed , added, deleted and finally send the appropriate requests back to the server.

Especially for edits I need to know the fields that were changed.

Is there an angular way to track these changes so that when the user presses "Update" I can build the 3 required requests and send them back to the server:

a) Update xx rows

b) Delete xx rows (they can easily be tracked when user presses delete button)

c) Insert xx rows

Upvotes: 0

Views: 204

Answers (1)

adam0101
adam0101

Reputation: 31055

I don't think AngularJS will do this for you automatically on a per object basis. You might be interested in something like http://www.breezejs.com/ which works with AngularJS. I've never used it, but I hear it does what you need.

Upvotes: 1

Related Questions