我是 AngularJS 的新手,觉得它很有趣,但我对以下情况有点不清楚。
app.factory('deleteFac', function($http){
var factory = {};
factory.edit = function(id){
$http.get('?controller=store&action=getDetail&id=' + id).
success(function(data, status){
/**
got an error on the following
when i use return data; and i get data undefined
in the controller which i get it because its doing a ajax call
you don't get data until the call first.
**/
$scope.detail = data;
})
}
return factory;
})
当我分配给$scope
并使用返回数据时出现错误,无论如何我可以将返回数据分配给$scope
?