1
나는이 튜토리얼 http://g00glen00b.be/spring-websockets-angular/ 아래의 stomp-websockets, sock.js와 함께 angular.js를 사용하고 있습니다. websocket에서 메시지를 받고 있지만 websocket의 메시지가 도착한 후에 템플릿보기가 새로 고쳐지지 않습니다. 템플릿보기를 업데이트하려면 입력 상자를 지우거나 마우스로 스크롤해야합니다.템플릿보기가 업데이트되지 않았습니다 -> 무언가 스크롤이 필요하거나 입력을 지울 필요가 없습니다
$scope.initiator = false;
$scope.socket = {
client: null,
stomp: null
};
$scope.initSockets = function() {
$scope.socket.client = new SockJS('/myUrl');
$scope.socket.stomp = Stomp.over($scope.socket.client);
$scope.notifyMessage = function(message) {
$scope.initiator = true;
$scope.messages.push(message)
};
$scope.socket.stomp.connect({}, function() {
$scope.socket.stomp.subscribe("/topic/messages", $scope.notifyMessage);
});
$scope.socket.client.onclose = $scope.reconnect;
};
$scope.initSockets();
template view:
<ul><li ng-repeat="item in messages track by $index">{{item}}</li></ul>