Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have a few choices...</p> <ol> <li><p>You could do polling every X milliseconds using <code>$timeout</code> and <code>$http</code>, or if the data you're using is hooked up to a REST service, you could use <code>$resource</code> instead of <code>$http</code>.</p></li> <li><p>You could create a service that uses some Websocket implementation and uses <code>scope.$apply</code> to handle changes that are pushed by the socket. Here's an example using socket.io, a node.js websocket library:</p> <pre><code>myApp.factory('Socket', function($rootScope) { var socket = io.connect('http://localhost:3000'); //Override socket.on to $apply the changes to angular return { on: function(eventName, fn) { socket.on(eventName, function(data) { $rootScope.$apply(function() { fn(data); }); }); }, emit: socket.emit }; }) function MyCtrl($scope, Socket) { Socket.on('content:changed', function(data) { $scope.data = data; }); $scope.submitContent = function() { socket.emit('content:changed', $scope.data); }; } </code></pre></li> <li><p>You could get really high tech and create a websocket implementation which syncs an Angular model with the server. When the client changes something, that change gets automatically sent to the server. Or if the server changes, it gets sent to the client.<br> Here's an example of that in an old version of Angular, again using socket.io: <a href="https://github.com/mhevery/angular-node-socketio">https://github.com/mhevery/angular-node-socketio</a></p></li> </ol> <p><strong>EDIT</strong>: For #3, I've been using <a href="http://firebase.com">Firebase</a> to do this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload