I am not aware of latest release of angularjs. I saw a piece of code like below
angular.module('app')
.controller('myApp', [myApp]);
function myApp() {
var vm = this;
vm.title = 'Customers';
vm.customers = [
{name: 'Haley'}, {name: 'Ella'}, {name: 'Landon'}, {name: 'John'}
];
};
instead of code i used to write earlier like
angular.module('app')
.controller('myApp', function($scope){
$scope.title = 'Customers';
$scope.customers = [
{name: 'Haley'}, {name: 'Ella'}, {name: 'Landon'}, {name: 'John'}
];
});
So why are we injecting the functionality required for the controller? what advantage does it provide. Correct me if my understanding is wrong.