mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-10-24 11:50:59 +08:00
AngularJS: give an interface to $http callback functions
- add IHttpPromiseCallback for both `error` and `success` promise calls use case is if we're passing around the callback, we don't want to be repeating that entire function declaration every time, and we cannot use `Function` as that doesn't satisfy the compiler. (see test case)
This commit is contained in:
1 parent
1c64851a71
commit
1a32cce3e0
2 files changed
+20
-2
No files matched your search
@@ -137,6 +137,20 @@ module HttpAndRegularPromiseTests {
|
||||
$scope.letters = letters;
|
||||
});
|
||||
}
|
||||
|
||||
// Test that we can pass around a type-checked success/error Promise Callback
|
||||
var anotherController: Function = ($scope: SomeControllerScope, $http:
|
||||
ng.IHttpService, $q: ng.IQService) => {
|
||||
|
||||
var buildFooData: Function = () => 42;
|
||||
|
||||
var doFoo: Function = (callback: ng.IHttpPromiseCallback) => {
|
||||
$http.get('/foo', buildFooData())
|
||||
.success(callback);
|
||||
}
|
||||
|
||||
doFoo((data) => console.log(data));
|
||||
}
|
||||
}
|
||||
|
||||
// Test for AngularJS Syntac
|
||||
|
||||
Reference in new issue
Block a user