0

The angular data / view binding is a great concept. The various REST - based libraries also make life pretty easy when transmitting data between the angular front-end and a remote server. In my case I am working with a Rails API-based server.

Has anyone seen any code in the wild which implements a angular-style data binding with a remote server? That would be ideal: update the $scope and both the view and remote server are updated. It would be even better if the reverse were true: changes in the remote server were push down to the clients.

Are there any projects like this?

2
  • 1
    Definitely checkout Firebase. It is a payed service, but it cuts out the need for a backend developer, which can save tens of thousands of dollars per year. They make it soooo easy to bind data to server data and have it pushed out to all listeners in real time. Commented Feb 28, 2014 at 19:12
  • Interesting. It's amazing how fast software technology is moving these days. Commented Feb 28, 2014 at 21:43

2 Answers 2

1

The closets project of what you want to achieve is Angular Fire, but beware Firebase is a payed Saas Service. Also you could also give a try for Meteor

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

Comments

1

We wrote our own data binding mechanism that synchronizes the angular.js model with a view model on the server side. The server is written in ASP.NET but i think this approach can be adapted to other server technologies.

For two-way binding where the server can update the client's view model in real time, you will always need a duplex transport layer that builds on long-polling or websockets. We use SignalR for that.

Initially, the whole server-side data model must be sent to the client. We serialize it to JSON and send it via SignalR.

Server-side changes of the C# view model properties are sent to the client as a packet containing the path to the property, e.g. Persons[42].Address.City, and the value itself, e.g. New York.

Client-side changes of the javascript view model properties are sent to the server in the same way. To catch the change events, we encapsulate all fields of the original javascript model in get/set properties where the setter sends the update packet to the server.

Server-side methods of the C# view model can be invoked in a similar way. All objects in the view model have an invokeMethod function that can be used like this: Products[42].Manufacturer.invokeMethod('SendEmail', 'mailsubject', 'mailbody'). This will send a packet to the server containing the method path Products[42].Manufacturer.SendEmail and the arguments as an array of ['mailsubject','mailbody'].

The source code can be found here: SharpAngie. For technologies other than .NET you probably just need the code from sharp-angie.js.

Comments

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.