I am new to angular.js
and currently writing my first project.
Currently my controllers look like this, for example:
function MyCtrl($scope, MyService) {
$scope.foo = MyService.doStuff();
}
They work just fine that way (so far), but I browsed the source of another AngularJS application and noticed they're using angular.module to create their controllers.
Why, if at all, would I want to do this in my own application?
If you have multiple angular applications on your page and they have controllers with the same name you'll need to use module.controller to avoid conflicts. The same if you want to avoid pollute the global namespace
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With