Why $scope is bad?

Once heard as saying that to use the scope is bad, tell us why this is so?
July 8th 19 at 11:44
3 answers
July 8th 19 at 11:46
In my practice, I ran across some inconvenience connected with the fact that the child will inherit the parent scope of the prototype thus it turns out that all of the variables listed above are present in the enclosed scope. If you got the same name peremennyh it is easy to catch the mistake of changing the wrong variable. Starting to work with ui-router with a bunch ulozenych States I immediately ran to this inexperience. With the ControllerAs syntax, as I understand it, your data are in the controller and not in scope and such errors do not occur.

p.s. I'm not a Pro on angular, just thinking out loud :)
July 8th 19 at 11:48
$scope is not bad, it's an outdated approach. Now ( angular 1.5+) application is a set of components. Each components has its own controller, which allows you to hang all binding.
$scope gives too much freedom: it is possible for example to seleti in the parent $scope, and there is something to change. It is very easy. And how hard it will be some time to support this mess.
July 8th 19 at 11:50
Maybe it was on $rootScope? If so, then use $rootScope, which is about the same as to use global variables.
I think the author is asking about the benefits of vs controllerAs syntax. $scope
I can not clearly answer this question, so I'll sit here and wait for knowledgeable people ) - Alysson_Gaylord commented on July 8th 19 at 11:53
Yes it is about the difference between $scope and as I would like to know - alphonso_Abbott commented on July 8th 19 at 11:56
The first is the use of $scope impairs the readability of the application logic. You don't have a controller assigned to $scope.readyToTransform and in another controller it hung @watch and all, following the developer when trying to read the logic of your application ready to kill you. - Isaias_Medhurst commented on July 8th 19 at 11:59

Find more questions by tags Angular