Answer the question
In order to leave comments, you need to log in
What's the difference how to connect modules?
Good day.
I connect the necessary modules to the controller in this way
app.controller('nameCtrl', function($scope) {
...
...
...
})
app.controller('nameCtrl', ['$scope', function($scope) {
...
...
...
}])
Answer the question
In order to leave comments, you need to log in
The second option is preferable.
When using minifiers in the first variant, the code will break, in the second it won't.
You can also use Dependency Inject, property $inject:
var nameCtrl = function($scope) {
// ...
}
nameCtrl.$inject = ['$scope'];
app.controller('nameCtrl', nameCtrl);
https://github.com/johnpapa/angular-styleguide There are a lot of useful and interesting things here. Before writing something, I advise you to look at best practices. Then you don't have to refactor a bunch of code :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question