Tuesday, January 30, 2018

How to write a program for different http methods in angularJS

The example above uses the .get method of the $http service.
The .get method is a shortcut method of the $http service. There are several shortcut methods:
  1. .delete()
  2. .get()
  3. .head()
  4. .jsonp()
  5. .patch()
  6. .post()
  7. .put()
Program


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"> 
  </script>
</head>
  <body>
     <div ng-app="ABC" ng-controller="DEF">
      <p>
       {{myWelcome}}
      </p>
     </div>
<script>
      var app = angular.module('ABC', []);
      app.controller('DEF', function($scope, $http)
       {
       $http
          ({ 
              method : "GET",
              url : "http://localhost/Rushi/Core%20JS/appajs.html"
            })
                .then(function mySuccess(response) 
               {
                  $scope.myWelcome = response.data;
              },
         function myError(response) 
         {
            $scope.myWelcome = response.statusText;
         });
      });
</script>
  </body>
</html>

Output


0 comments:

Post a Comment

Thanks For Commented.

TechTalk