Please enable JavaScript.
Coggle requires JavaScript to display documents.
Angular 10 Best Practices (Controller bloat (Controllers should never do…
Angular 10 Best Practices
MVC directory structure
keeping the files grouped by type (traditional)
group files based on features (less confusion for developer)
Modules (or lack thereof)
Dependency injection
Global Dependencies
pass the dependencies as an array of strings with function as last parameter
eg: angular.controller('mycontrollername',['$scope','$http',function($scope,$http)]
very useful for minified version generated using tools like UGLIFYJS
Controller bloat
Controllers should never do DOM manipulation or hold DOM selectors
-Business logic should live in services
-Data should also be stored in services, except where it is being bound to the $scope.
Directives for DOM Manipulations
Services are singletons that persist throughout the lifetime of the application, while controllers are transient between application states. If data is stored in the controller then it will need to be fetched from somewhere when it is reinstantiated. Even if the data is stored in localStorage, it's an order of magnitude slower to retrieve than from with a Javascript variable.
AngularJS works best when following the Single Responsibility Principle (SRP). If the controller is a coordinator between the view and the model, then the amount of logic it has should be minimal. This will also make testing much simpler.
Service vs Factory
Not utilizing Batarang
Too many watchers
consider using
bindonce
Directive form github
Scoping $scope's
Manual Testing
Using jQuery