I'm writing a simple AngularJS script to load data from a socket.io event and then add it to the ng template, this is my JS:
// Socket.io logic:
var messages = [];
socket.on("chat message", function(message){
messages.push(message); //message = {username: String, text: String}
});
// AngularJS logic:
var app = angular.module("chat", []);
app.controller("MessagesCtrl", function ($scope) {
$scope.messages = messages;
})
Now I'd like to understand how to update my ng template when a new message is added to my messages[]...
This is an example fiddle with one attempt: http://jsfiddle.net/v8v67ohn/1/
As you can see, clicking the button nothing happens...
What am I doing wrong?