Answer the question
In order to leave comments, you need to log in
Issue with socket.io on client?
I have a controller:
Client code:
.controller('chatNotificationCtrl', ['$scope', 'socket', 'toastr', '$http', function($scope, socket, toastr, $http) {
$scope.chatNotifications = {};
if ($scope.logged) {
$scope.chatNotifications = $scope.logged.chatNotify;
} else {
return;
}
socket.on('notify:chat', function(data) {
console.log('NOTIFY CHAT');
$scope.chatNotifications.unshift(data);
toastr.success('Example', 'New Message');
});
$scope.$on('$destroy', function() {
socket.removeAllListeners();
});
}]);
Код сервера:
io.sockets.to(message.users).emit('notify:chat', newChatNotify);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question