AngularJS Syntax of $http.post in Different Versions

The http post action in AngularJS versions is designed with different syntaxes:

We normally use or see lots of online source code as $http…post…success(function ())…error(function()), but it is the syntax in AngularJS v1.3.20, The most recent AngularJS version might be v1.5.8x, and we could find many syntax changing in new versions.

For the AngularJS $http.post syntax:

The newest AngularJS use the following syntax:

$http({
  method: ‘POST’,
  url: ‘/someUrl’,
  data,
  config
}).then(function successCallback(response) {
    // this callback will be called asynchronously
    // when the response is available
  }, function errorCallback(response) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });

The following is the shortcut syntax and different syntax in different versions:

AngularJS v1.3.x

 $http.post(url, data, config)
            .success(function (data, status, headers, config) {
            })
            .error(function (data, status, header, config) {
            });

AngularJS v 1.4x, v 1.5x:

$http.post(url, data, config)
   .then(
       function(response){
         // success callback
       },
       function(response){
         // failure callback
       }
    );

Check more details information from AngularJS official document website.