I have seen angular services implementation in below two ways:
angular.module('my.service.MyService', []).service('MyService', function() {
return {
getMyDetails: getMyDetails,
};
function getMyDetails(filterParams) {
return $http({
method : 'get',
data : JSON.stringify(filterParams),
url : "/getMyList",
headers : {
'Content-Type' : 'application/json'
}
});
}
});
And
angular.module('my.service.MyService', []).service('MyService', function() {
this.getMyDetails = function getMyDetails(filterParams) {
return $http({
method : 'get',
data : JSON.stringify(filterParams),
url : "/getMyList",
headers : {
'Content-Type' : 'application/json'
}
});
};
});
Is there any advantages of using one or another ? (e.g. Closures or memory leaks )