Angularjs承诺不绑定到模板在1.2

升级到1.2之后,我的服务返回的promise具有不同的行为…
简单服务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自动绑定失败在所有我简单的服务….任何想法,我可能会做错了。

1.2.0-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.

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...