Uncaught TypeError: $rootScope.apply is not a function


#1

I’m trying to use socket but I am getting this error someone could help me

.factory(‘socket’,[’$rootScope’,function($rootScope){

    var socket = io.connect('http://192.168.0.133:8383/');
    return {
        on: function (eventName, callback) {
            socket.on(eventName, function () {
                var args = arguments;
                $rootScope.apply(function () {
                    callback.apply(socket, args);
                });
            });
        },
        emit: function (eventName, data, callback) {
            socket.emit(eventName, data, function () {
                var args = arguments;
                $rootScope.apply(function () {
                    if (callback) {
                        callback.apply(socket, args);
                    }
                });
            })
        }
    }}
])