Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
In my practice, I came across some inconveniences related to the fact that child scopes prototypically inherit parent ones, while it turns out that all the variables declared above are present in the nested scope itself. If you have the same variable names there, then it is easy to catch an error by changing the wrong variable. Starting to work with ui-router with a bunch of nested states, I immediately ran into this due to inexperience. With the ControllerAs syntax, as I understand it, your data is in the controller and not in the scope and such errors do not occur.
ps I'm not a pro at angular, just thinking out loud :)
$scope is not bad, it's an outdated approach. Now (angular 1.5+) an application is a collection of components. Each component has its own controller, which allows you to hang all the bindings.
$scope gives too much liberties: for example, you can fly into the parent $scope and change something there. It is very easy. And how hard it will be after a while to maintain this mess.
Maybe it was about $rootScope? If so, then using $rootScope is about the same as using global variables.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question