2

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?

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

5 Comments

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.
Use scope.$apply for that now docs.angularjs.org/api/ng.$rootScope.Scope#$apply. Example: scope.$apply(function() { scope.myValue = 6; });
Hope this isn't a dumb question, but when I define my service, do I pass in $apply?
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.
There's no such thing as a dumb question. :) and you can inject $rootScope into your service and do $rootScope.$apply();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.