Richard Searle's Blog

Thoughts about software

Angular, SSE and modifying a list model

Posted by eggsearle on April 8, 2012

The previous example used a very simple model, consisting of a single String.

A more realistic implementation would add the strings to a list.

<body ng-app>
 <div ng:controller="Main">
 <li ng:repeat="item in items">

<script type='text/javascript'>//<![CDATA[

var source = new EventSource('/events');

function Main($scope) {
 $scope.items = [];

source.addEventListener('right', function(e) {
 $scope.$apply(function() {

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: