Currently, I am in the process of creating a basic chat application using express.js
, socket.io
, and angular
. The functionality seems to be working properly. However, I am encountering an issue where the socket message event is not synchronizing and displaying on the page correctly.
var socket = io.connect('http://localhost:8080');
angular.module('chat',[]).controller('chatController',['$scope','$apply',function($scope,$apply){
chat = $scope;
chat.messages = [];
socket.on('messages',function(data){
chat.$apply(function(){
chat.messages.push(data);
});
});
}])
I understand that I need to use `$apply` in some way, but I keep receiving an error mentioning an unknown provider. Can someone guide me on the correct approach to implementing $apply
?