While delving into the Angular documentation, I came across a question regarding the difference between two variations of controller constructors. The first one looks like this:
angular.module('myApp', [])
.controller('SomeController', function() {
this.qty = 1;
});
And the second one is structured as follows:
angular.module('myApp', [])
.controller('SomeController', ['$scope', function($scope) {
$scope.qty = 1;
}]);
I would like to know which approach is generally preferred and the reason behind it. Additionally, what additional benefits does injecting the $scope object provide?