PatrickJS / angular-websocket

:arrow_upper_left: The missing Angular WebSocket module for connecting client applications to servers by @AngularClass
https://angularclass.github.io/angular-websocket
MIT License
1.22k stars 195 forks source link

Cannot read property 'readyState' of undefined #69

Open qidaneix opened 8 years ago

qidaneix commented 8 years ago

when I using $websocket.send() I get this error message and without any other information, what's wrong with that? here is my code:

//service
app.factory('mySock',
    ['$websocket',
        function($websocket){
            return $websocket('ws://www.cspebank.cn:8080/ws.do');
        }
    ]
);
//service
app.factory('news',
    [ 'mySock',
        function (mySock) {
            var news = {
                  mySock.send(JSON.stringify({ data: 'data' }));
            };
            return news;
        }
    ]
);
app.controller(
    'appController', [
        '$scope', 'news',
        function($scope, news){
            $scope.news = news;
        }
    ]
);

thank you!