AngularJS with SignalR
angularjs, signalr
Solution
`$scope` does not exist in this context as that's something injected when a controller is created and a new child scope is made. However, `$rootScope` is available at the time you need.
Also, be aware `$emit()` goes upward and your controller scopes wont see it. You would either need to switch to `$broadcast()` so the event goes downwards or inject `$rootScope` as well to the controllers you want to be able to subscribe to `'numberOfIncidents'`
Check out the angular docs and a useful wiki on scopes.
Problem
I am playing with Angular and SignalR, I have tried to create a service which will act as a manager. ``` dashboard.factory('notificationsHub', function ($scope) { var connection; var proxy; var initialize = function () { connection = $.hubConnection(); proxy = connection.createHubProxy('notification'); proxy.on('numberOfIncidents', function (numOfIncident) { console.log(numOfIncident); $scope.$emit('numberOfIncidents', numOfIncident); }); connection.start() .done(function() { console.log('Connected'); }) .fail(function() { console.log('Failed to connect Connected'); }); }; return { initialize: initialize }; }); ``` however I get the error `Error: Unknown provider: $scopeProvider <- $scope <- notificationsHub`. How can I use `pubsub` to pass all the notifications to the controllers? jQuery maybe?