diff --git a/angular-ui-router/angular-ui-router-tests.ts b/angular-ui-router/angular-ui-router-tests.ts index 38ddcca26b..174c319f97 100644 --- a/angular-ui-router/angular-ui-router-tests.ts +++ b/angular-ui-router/angular-ui-router-tests.ts @@ -143,7 +143,7 @@ class UrlLocatorTestService implements IUrlLocatorTestService { private $state: ng.ui.IStateService ) { $rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event)); - $rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) => + $rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) => this.onStateNotFound(event, unfoundState, fromState, fromParams)); } @@ -157,8 +157,8 @@ class UrlLocatorTestService implements IUrlLocatorTestService { // Note that we do not concern ourselves with what to do if this request fails, // because if it fails, the web page will be redirected away to the login screen. - this.$http({ url: "/api/me", method: "GET" }).success((user: any) => { - this.currentUser = user; + this.$http({ url: "/api/me", method: "GET" }).then((response: ng.IHttpPromiseCallbackArg) => { + this.currentUser = response.data; // sync the ui-state with the location in the browser, which effectively // restarts the state change that was stopped previously @@ -166,14 +166,14 @@ class UrlLocatorTestService implements IUrlLocatorTestService { }); } } - + private onStateNotFound(event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) { var unfoundTo: string = unfoundState.to; var unfoundToParams: {} = unfoundState.toParams; - var unfoundOptions: ng.ui.IStateOptions = unfoundState.options + var unfoundOptions: ng.ui.IStateOptions = unfoundState.options } private stateServiceTest() { diff --git a/angular/angular-tests.ts b/angular/angular-tests.ts index cca4dfc420..8634269fb0 100644 --- a/angular/angular-tests.ts +++ b/angular/angular-tests.ts @@ -108,11 +108,6 @@ namespace HttpAndRegularPromiseTests { } function someController($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) { - $http.get('http://somewhere/some/resource') - .success((data: ExpectedResponse) => { - $scope.person = data; - }); - $http.get('http://somewhere/some/resource') .then((response: ng.IHttpPromiseCallbackArg) => { // typing lost, so something like @@ -156,21 +151,6 @@ namespace HttpAndRegularPromiseTests { $scope.nothing = 'really nothing'; }); } - - // Test that we can pass around a type-checked success/error Promise Callback - function anotherController($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) { - function buildFooData(): ng.IRequestShortcutConfig { - return {}; - } - - function doFoo(callback: ng.IHttpPromiseCallback) { - $http - .get('/foo', buildFooData()) - .success(callback); - }; - - doFoo((data: any) => console.log(data)); - }; } // Test for AngularJS Syntax @@ -441,10 +421,10 @@ httpFoo.then((x) => { x.toFixed(); }); -httpFoo.success((data, status, headers, config) => { - const h = headers('test'); +httpFoo.then((response: ng.IHttpPromiseCallbackArg) => { + const h = response.headers('test'); h.charAt(0); - const hs = headers(); + const hs = response.headers(); hs['content-type'].charAt(1); }); diff --git a/ng-file-upload/ng-file-upload-tests.ts b/ng-file-upload/ng-file-upload-tests.ts index 7252231661..08fbafdb6b 100644 --- a/ng-file-upload/ng-file-upload-tests.ts +++ b/ng-file-upload/ng-file-upload-tests.ts @@ -26,7 +26,7 @@ class UploadController { ngfValidateForce: true }); } - + onFileSelect(files: Array) { this.Upload @@ -44,11 +44,11 @@ class UploadController { }).progress((evt: angular.angularFileUpload.IFileProgressEvent) => { let percent = parseInt((100.0 * evt.loaded / evt.total).toString(), 10); console.log("upload progress: " + percent + "% for " + evt.config.data.media[0]); - }).error((data: any, status: number, response: any, headers: any) => { - console.error(data, status, response, headers); - }).success((data: any, status: number, headers: any, config: angular.angularFileUpload.IFileUploadConfigFile) => { + }).catch((response: ng.IHttpPromiseCallbackArg) => { + console.error(response.data, response.status, response.statusText, response.headers); + }).then((response: ng.IHttpPromiseCallbackArg) => { // file is uploaded successfully - console.log("Success!", data, status, headers, config); + console.log("Success!", response.data, response.status, response.headers, response.config); }); this.Upload @@ -72,16 +72,16 @@ class UploadController { this.Upload.isResizeSupported(); this.Upload.isResumeSupported(); this.Upload.isUploadInProgress(); - + let json = this.Upload.json({ test: true }), jsonBlob = this.Upload.jsonBlob({ test: true }), fileWithNewName = this.Upload.rename(files[0], "newName.jpg"); this.Upload - .resize(files[0], { + .resize(files[0], { height: 1024, width: 1024, - quality: 0.7, + quality: 0.7, ratio: 0.9, centerCrop: true, restoreExif: true,