search

Home  >  Q&A  >  body text

angular.js - angularjs用websocket做聊天功能发送不出去消息

点击发送按钮触发,消息发不出去
controller:

var ws = new WebSocket("ws://121.43.160.149:8890/ws/phone/message");
        var chatMessage = {
            messagetxt : $scope.mmm,
            touserid : thisId
        }
        var sMsg = {
            messageContext : chatMessage,
            messageType : "friendChat"
        }
        console.log(sMsg);
        ws.onopen = function(e){
            ws.send(JSON.stringify(sMsg));
        }

请问angularjs在用webSocket时应该怎么用?

仅有的幸福仅有的幸福2744 days ago564

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-15 17:07:37

    Just look at the information on github, it has detailed instructions
    https://github.com/AngularCla...

    reply
    0
  • Cancelreply