I'm trying to refresh the controller of my angular app to receiving objects from socket.io. Everything works fine except that the view don't show when I add a new object to the variable with the push function. Here's my code.
Controller.js
app.controller('controller', function(){
var vm = this;
var socket = io.connect('http://localhost:3000');
//The variable that bends
vm.messages = [];
socket.on("addMsg", function(obj){
vm.messages.push({user: obj.user, content: obj.content, color:obj.col});
});
});
view.jade
...
body(ng-controller = "controller as con")
.messages
p Messages:
p(ng-repeat="array in con.messages") content: {{array.content}} , color: {{array.color}}
Whats wrong with my code?, the purpose is to show all content in p tag using ng-repeat.