(function() {
angular.module('MyApp')
.factory('Contact', Contact);
Contact.$inject = ['$http'];
function Contact($http) {
return {
send: function(data) {
return $http.post('/contact', data);
}
};
}
})();
In a boilerplate I found above code. I have few confusions :
why not just inject
$http
like thisangular.module('MyApp').factory('Contact', function($http){ });
is it necessary to put the service within self-execution function?