Tuesday, January 30, 2018

How to write a program for diffrent http Properties in angularJS.

  • The response from the server is an object with these properties:
    • .config the object used to generate the request.
    • .data a string, or an object, carrying the response from the server.
    • .headers a function to use to get header information.
    • .status a number defining the HTTP status.
    • .statusText a string defining the HTTP status.
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> data {{ content }}</p>
    <p> status {{ statuscode }}</p>
    <p> text {{ statustext}}</p>
    </div>
<script>
    var app = angular.module('abc', []);
    app.controller('def', function($scope, $http)
    {
      $http.get("appajs.html").then(function(response)
        {
          $scope.content = response.data;
          $scope.statuscode = response.status;
          $scope.statustext = response.statusText;          
        });
    });
</script>
</body>

</html>

Output



0 comments:

Post a Comment

Thanks For Commented.

TechTalk