for*_*yez 2 javascript ajax jquery angularjs
我不明白何时使用Angular over jquery来获取ajax请求.
例如,我为什么要使用:
function ItemListCtrl ($scope, $http) {
$http.get('example.com/items').success(function (data) {
$scope.items = data;
}
}
Run Code Online (Sandbox Code Playgroud)
代替
function ItemListCtrl ($scope) {
$.ajax({type: "GET", url: 'example.com/items',
success: function (result) {
$scope.items = data;
}
});
}
Run Code Online (Sandbox Code Playgroud)
??
我的理解是,有一些原因首先是首选的:
除此之外,你通常应该能够做到.
| 归档时间: |
|
| 查看次数: |
1352 次 |
| 最近记录: |