Here is a tutorial for the 7 best practices for working with $scopes in AngularJS.


#1 – Keep the $rootScope clean of variables

This rule is based on the idea that the $rootScope is a global variable and falls under the best practice that Global Variables Are Bad. Adding variables to the$rootScope will result in source code that is difficult to maintain. The usage of those variables will be scattered across JavaScript files, directives, controllers and templates. It will also make it difficult to unit test source code and do refactoring.

See on

Posted in: Articles.
Last Modified: February 26, 2015

Leave a Reply