3 ms·
I realize this is a basic question, but how does synchronization between the client and server work with Angular? I understand the concept of data-binding once
by uptown 13y ago
I realize this is a basic question, but how does synchronization between the client and server work with Angular? I understand the concept of data-binding once you've retrieved the data to a data-structure on the client-side, thus causing that data to update the view in the DOM, but what triggers a client-side update when your server-side data changes? Do you need to poll a REST service to check for changes? Does the server push the change to the client side? Say there's no client-action triggering an update? What causes the new server-data to get pushed to the client?
- candybar 13y agoAngularJS is not a server-side framework and therefore it is agnostic on that question. You can do it however you like and you can even create directives that keep the client model synchronized with server-side, but it doesn't come out of the box.
- uptown 13y agoSo if you want to poll a service periodically, you can do that ... or if you want to use a websocket and just leave a pipe open to refresh your client-side model ... you can do that too? Got it. Thanks.
- yoshokatana 13y agoYep. The $http service in angular core basically does your standard Http stuff (with some nifty additions like caching and promises), but people have built services to do sockets, sails, handle server-side events, etc.
- nawitus 13y agoYou should actually use a service to keep data synchronized.