I have this piece of code:
.service('webSocket', function ($rootScope, socketFactory, CONFIG, $timeout) { angular.element(document).ready(function () { $rootScope.log('Waiting for connection...',CONSOLE_INFO); }); And I am getting this error:
TypeError: $rootScope.log is not a function
This service is injected into this controller:
.controller('mainCtrl', function mainCtrl($scope, $rootScope, webSocket, myConsole ... In which I have:
$rootScope.log = function (msg, type) { myConsole.log(msg,type); ... }; Can you tell me where is the problem? Or at least point me in the right direction? The reason I am using document ready function is because apart from logging messages to browser console (console.log) I use notifications for user (pNotify library) which needs to be called after DOM is loaded.
logfunction in theAngular.runstartup method.$logservice or yourmyConsoleservice directly from yourwebSocketservice?