【发布时间】:2014-10-30 19:13:18
【问题描述】:
我想知道 AngularJS 中是否有以下内容的糖速记:
$scope.parseSomeString = function (str) {
console.log(str);
// ...
};
someService.fnA($scope.arg1) // fnA doesn't return anything
.then(function () {
return someService.fnB($scope.arg2, $scope.arg3()) // fnB returns some, e.g. string
})
.then($scope.parseSomeString); // this shorthand is great!
我想做的是这样的:
someService.fnA($scope.arg1)
.then(someService.fnB($scope.arg2, $scope.arg3())) // but of course, this just calls the function; not good
.then($scope.parseSomeString); // this shorthand is great!
有什么方法可以将参数$scope.arg2 和$scope.arg3() 绑定到fnB?
【问题讨论】:
-
你也可以装饰 $q 并为其添加一个
.fcall构造
标签: angularjs promise q angular-promise