我想知道是否有糖简写为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'构造 – 2014-09-06 11:25:39