Trying to decide between using the $http service in Angular the traditional way or the shortcut method – which one is better? Is there any impact on development, performance, or is it just a matter of personal preference?
Personally, I lean towards the traditional longhand approach as I find it more readable and like having more line breaks in my code:
$http({
method: 'POST',
url: '/api/mydata',
data: JSON.stringify($scope.myData),
headers: {
'Content-Type': 'application/json'
}
})
.then(getReportDataComplete)
.catch(getReportDataFailed);
Comparing this to the shortcut method:
$http.post('api/mydata/',{
data: JSON.stringify($scope.myData),
headers: {
'Content-Type': 'application/json'
}
})
.then(getReportDataComplete)
.catch(getReportDataFailed);