0

I've been using angularJS to build a website/business system for my mum's business. I'm not quite sure what would be best practice for the bit i'm working on just now.

I'm using PDO to handle the data on the database

I need to implement the option to change client details.

I my first instinct was to use ng-change so that the data saves as soon as it's changed. but I'm not sure if that's the best way to do it (think of the number of requests that would have to be sent when making a note. I had also though of saving changes when the user leaves the text box, or just adding a save button.

Which way is best?... or does it really not matter?

miquelarranz
  • 876
  • 11
  • 26
Jamie McAllister
  • 729
  • 2
  • 11
  • 33
  • Depends on the rollback strategy you want to use. Always have to consider that requests can fail. Nobody can answer this for you...we don't know enough about your app – charlietfl Jun 28 '16 at 11:42
  • you know... sometimes i feel my degree was worthless.... rollback strategy? heh... i guess i have some googling to do :/ – Jamie McAllister Jun 28 '16 at 12:06
  • Nothing complicated... if you live edit and request fails need to alert user and revert whatever original was. If use save button then only update live data on success of server updte – charlietfl Jun 28 '16 at 12:49

1 Answers1

0

Yes you are correct - using ng-change will increase the number of requests.

but the developers at google have made sure that logic behind ng-change is optimised for best performance.

check these articles for further explanation

http://www.codelord.net/2015/06/11/using-ng-change-instead-of-$watch-in-angular/

How does data binding work in AngularJS?

Community
  • 1
  • 1