You forgot to inject the $scope
into your controller itself:
app.controller('MainCtrl', function ($scope, Socket) {
$scope.objects = {};
// do something with $scope.objects, etc.
});
But this still won´t help you to access the "objects" of this controller via the rootScope, since $scope inherhits $rootScope, but not the other way around - so whatever you define on the $scope
wont be propagated to the $rootScope
.
What you CAN do however is to link the $scope.objects
with a varibale inside your factory itself, so something like this:
var app = angular.module('mainMod', ['apiService']);
app.controller('MainCtrl', function (Socket) {
$scope.objects = Socket.objects = {};
// do something with $scope.objects, etc.
});
And in your Socket-Factory:
apiService.factory('Socket', ['$rootScope', function ($rootScope) {
return {
objects : {}
}
}]);
Just be careful then to not overwrite the $scope.objects
directly, since it will break the reference again.