我想知道是否有糖簡寫爲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