I would like to persuade my co-worker that it is a better approach to use component directives than to use $rootScope
everywhere. I need arguments against his ones because he is very stubborn and a very good speaker (which I am not). He thinks that $rootScope
prevents spaghetti code. This week I have refactored the project and there are no more spaghetti but I don't want him to rework everything to $rootScope
.
Please tell me about problems and issues that can arise when using $rootScope
. Thank you.
EDIT
Are there any security issues with $rootScope
?
EDIT 2
My friend came with this construct and wants to put it in every component:
function Controller(service, $rootScope, $scope) {
var vm = this;
$scope.a = $rootScope.a;
$scope.b = $rootScope.b;
$scope.c = $rootScope.c;
$rootScope.$watch('mapLoaded', function () {
$scope.a = $rootScope.a;
$scope.b = $rootScope.b;
$scope.c = $rootScope.c;
}, true);
Would the issue of destroying scopes and removing wathces that @charlietfl described in comments appear? I am definitelly not gonna let him code like this but I need the arguments against it. Thanks again.