I'd like to use socketstream's RPC over websockets abstraction while using Angular for MVC. Can anyone (probably in the Angular community) point me in the right direction to learn how to use a custom RPC-type data source to update Angular's models in the most idiomatic way?
Asked
Active
Viewed 2,586 times
1 Answers
4
If you want to simply sync a model with the server, here's a good example to start with that Misko Hevery made for socket.io: https://github.com/mhevery/angular-node-socketio

Andrew Joslin
- 43,033
- 21
- 100
- 75
-
OK, so basically I have to define a service that listens for updates from both the GUI and the server and syncs them. One Q-- he uses $updateView, but that seems to be deprecated. Basically what I'm looking for is how to idiomatically tell Angular that the model has changed so that it can update any data bound elements. – BHP Jun 25 '12 at 22:32
-
Use scope.$apply for that now http://docs.angularjs.org/api/ng.$rootScope.Scope#$apply. Example: scope.$apply(function() { scope.myValue = 6; }); – Andrew Joslin Jun 25 '12 at 22:51
-
Hope this isn't a dumb question, but when I define my service, do I pass in $apply? – BHP Jun 26 '12 at 02:53
-
i mean in this part of the example: angular.service('sharedModel', function($updateView). just trying to understand the context that the service will be called when I make it a dependency of one of my controllers. – BHP Jun 26 '12 at 02:55
-
There's no such thing as a dumb question. :) and you can inject $rootScope into your service and do $rootScope.$apply(); – Andrew Joslin Jun 26 '12 at 12:10