Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

$http's deprecated custom callback methods #1990

Merged
merged 3 commits into from
Dec 31, 2016

Conversation

anteriovieira
Copy link
Contributor

@anteriovieira anteriovieira commented Dec 30, 2016

This PR fixes #1989.

The .success and .error methods are deprecated and have been removed from AngularJS 1.6. Use the standard .then and .catch method instead.

Before:

$http(...).
success(function onSuccess(data, status, headers, config) {
  // Handle success
  ...
}).
error(function onError(data, status, headers, config) {
  // Handle error
  ...
});

After:

$http(...).
  then(function onSuccess(response) {
    // Handle success
    var data = response.data;
    var status = response.status;
    var statusText = response.statusText;
    var headers = response.headers;
    var config = response.config;
    ...
  }, function onError(response) {
    // Handle error
    var data = response.data;
    var status = response.status;
    var statusText = response.statusText;
    var headers = response.headers;
    var config = response.config;
    ...
  });

// or

$http(...).
  then(function onSuccess(response) {
    // Handle success
    var data = response.data;
    var status = response.status;
    var statusText = response.statusText;
    var headers = response.headers;
    var config = response.config;
    ...
  }).
  catch(function onError(response) {
    // Handle error
    var data = response.data;
    var status = response.status;
    var statusText = response.statusText;
    var headers = response.headers;
    var config = response.config;
    ...
  });

@@ -42,7 +42,7 @@ angular.module('uiGmapgoogle-maps')
$templateCache.put 'uigmap-searchbox-default.tpl.html', '<input type="text">'
scope.template = 'uigmap-searchbox-default.tpl.html'
$http.get(scope.template, { cache: $templateCache })
.success (template) =>
.then (template) =>
Copy link
Contributor

@nmccready nmccready Dec 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need .then (template) => template.data or .then ({data}) => here as well.

@nmccready nmccready merged commit 75f3bc4 into angular-ui:master Dec 31, 2016
@anteriovieira anteriovieira deleted the angular-1.6 branch December 31, 2016 14:34
@akrawchyk
Copy link

akrawchyk commented Mar 29, 2018

This didn't bump the semvar version in bower.json to allow it to be installed for angular 1.6... The range 1.2 - 1.6 is parsed to >=1.2 <1.6 so this fails to meet dependencies for angular >=1.6 unfortunately.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

angular-google-maps fails when upgrading to Angular 1.6.x
3 participants