为此使用手表是很丑的。
试试这个:
datModule.factory('datfactory', function ($http, $q){ this.getlist = function(){ return $http.get('http://localhost:61686/getdatlist?format=json',{'Access-Control-Allow-Origin': 'localhost:*'}) .then(function(response) { console.log(response); //I get the correct items, all seems ok here return response.data.itemsToReturn; }); } return this;});datModule.controller('datlist', function ($scope, datfactory){ datfactory.getlist() .then(function(arrItems){ $scope.items = arrItems; });});这就是您对异步事务使用promise的方式。
更新(15.01.2015):现在更时尚!



