我不明白何时对ajax请求使用Angular over jquery。
例如,为什么要使用:
function ItemListCtrl ($scope, $http) { $http.get('example.com/items').success(function (data) { $scope.items = data; } }
代替
function ItemListCtrl ($scope) { $.ajax({type: "GET", url: 'example.com/items', success: function (result) { $scope.items = data; } }); }
??
我的理解是,首选第一个原因有两个:
除了这些之外,您通常应该能够执行任何一项操作。