0
我試圖選擇在Angular中使用$ http服務的標準 - longhand or shorthand/shortcut
爲了開發目的,兩者之間是否有區別?表演還是其他?或者它只是降低偏好?
我更喜歡手寫的,我覺得它更具可讀性和喜歡更多的換行符:
$http({
method: 'POST',
url: '/api/mydata',
data: JSON.stringify($scope.myData),
headers: {
'Content-Type': 'application/json'
}
})
.then(getReportDataComplete)
.catch(getReportDataFailed);
相比於:
$http.post('api/mydata/',{
data: JSON.stringify($scope.myData),
headers: {
'Content-Type': 'application/json'
}
})
.then(getReportDataComplete)
.catch(getReportDataFailed);