btford / angular-socket-io

Socket.IO component for AngularJS
1.51k stars 233 forks source link

scope.$on is not a function #164

Open alikenski opened 5 years ago

alikenski commented 5 years ago

I have a one error: scope.$on is not a function at http://URL/js/socket/directive.socket.js:92:21

forward: function (events, scope) { if (events instanceof Array === false) { events = [events]; } if (!scope) { scope = defaultScope; } events.forEach(function (eventName) { var prefixedEvent = prefix + eventName; var forwardBroadcast = asyncAngularify(socket, function () { Array.prototype.unshift.call(arguments, prefixedEvent); scope.$broadcast.apply(scope, arguments); }); **scope.$on**('$destroy', function () { socket.removeListener(eventName, forwardBroadcast); }); socket.on(eventName, forwardBroadcast); }); }