我试图从工厂调用 ajax,但它没有返回任何东西。我的代码如下
var msfaWebPortal = angular.module('MsfaWebPortal', [])
.factory('personFactory', function () {
var factory = {};
var people = [];
$.ajax({
url: '@Url.Action("GetPerson","Home")',
success: function (data) {
people = data;
}
});
factory.getPerson = function () {
return people;
};
return factory;
})
.controller('PersonCtrl', function ($scope, personFactory) {
$scope.friends = personFactory.getPerson();
$scope.predicate = '-age';
});
我错过了什么吗?或者我该怎么做?请帮帮我。