onopen not responding in angular websocket

时间:2015-04-23 05:14:38

标签: javascript angularjs node.js websocket mean-stack

I'm new to websockets and i'm simply trying to get the server to respond when opening my app in the browser, but the connection.onopen is not responding as expected. Thanks for any help you can provide.

angular.module('app')
.run(function ($rootScope) {
    var url = 'ws://localhost:3000'
    var connection = new WebSocket(url)

    connection.onopen = function () {
        console.log('WebSocket connected')
    }
})

0 个答案:

没有答案