升级到1.2后,我的服务返回的承诺表现不同......简单的服务myDates:
getDates: function () {
var deferred = $q.defer();
$http.get(aGoodURL).
success(function (data, status, headers, config) {
deferred.resolve(data); // we get to here fine.
})......
Run Code Online (Sandbox Code Playgroud)
在早期版本中,我可以在我的控制器中执行:
$scope.theDates = myDates.getDates();
Run Code Online (Sandbox Code Playgroud)
并且从getDates返回的promise可以直接绑定到Select元素.现在这不起作用,我被迫在我的控制器中提供回调或数据不会绑定:
$scope.theDates = matchDates.getDates();
$scope.theDates.then(function (data) {
$scope.theDates = data; // this wasn't necessary in the past
Run Code Online (Sandbox Code Playgroud)
文档仍然说:
$ q promises被临界引擎识别为angular,这意味着在模板中,您可以将附加到范围的promise视为结果值.
他们(承诺)在Angular的旧版本中工作,但是在我所有的简单服务中,1.2 RC3自动绑定都失败了....任何关于我可能做错的想法.
angularjs ×1