【发布时间】:2013-08-05 03:33:21
【问题描述】:
在 angularjs 中,通常在 Promise 的 then 方法中,您需要对范围进行一些更改,这需要您将代码包装在 $scope.$apply(.. .)。 我想知道是否以及如何扩展承诺以提供 thenapply 函数,这将不再需要您进行包装,所以而不是
myPromise.then(function() { $scope.$apply(function(data) { $scope.message=data.message; }) });
你可以写:
myPromise.thenapply( function() { $scope.message=data.message; });
【问题讨论】: