观看这部影片,AngularJS如何从异步调用返回值?
https://www.youtube.com/watch?v=IRelx4-ISbs
你会发现,代码行写这个:
$scope.twitterResult = $scope.twitter.get({q:$scope.searchTerm});
这是一个垃圾的怪癖: “叽叽喳喳的“获得”的方法'显然是一个异步函数,它如何将值返回给$ scope.twitterResult?
的jsfiddle(不能工作的原因Twitter的API已经改变):
http://jsfiddle.net/johnlindquist/qmNvq/
相关:http://stackoverflow.com/q/15464273/497356 –