简单服务myDates:
getDates: function () { var deferred = $q.defer(); $http.get(aGoodURL). success(function (data,status,headers,config) { deferred.resolve(data); // we get to here fine. })......
在早期版本中我只能做,在我的控制器:
$scope.theDates = myDates.getDates();
并且从getDates返回的promise可以直接绑定到Select元素。
现在这不工作,我被迫提供一个回调的promise在我的控制器或数据不绑定:
$scope.theDates = matchDates.getDates(); $scope.theDates.then(function (data) { $scope.theDates = data; // this wasn't necessary in the past
文档仍然说:
$ q promises由模板引擎在角度中识别,这意味着在模板中,您可以将附加到作用域的promise视为结果值。
他们(承诺)在旧版本的Angular工作,但在1.2 RC3自动绑定失败在所有我简单的服务….任何想法,我可能会做错了。
AngularJS 1.2.0-rc3 ferocIoUs-twitch fixes a number of high priority
issues in $compile and $animate and paves the way for 1.2.
This release also introduces some important breaking changes that in some cases Could break your directives and templates. Please
be sure to read the changelog to understand these changes and learn
how to migrate your code if needed.
For full details in this release,see the 07000.
更改日志中有描述:
$parse:
- due to 07001,$parse and templates in general will no longer automatically unwrap promises. This feature has been deprecated and
if absolutely needed,it can be reenabled during transitional period
via$parseProvider.unwrapPromises(true)
api.- due to 07002,feature added in rc.2 that unwraps return values from functions if the values are promises (if promise unwrapping is enabled – see prevIoUs point),was reverted due to breaking a popular usage pattern.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。