Tuesday, 21 March 2017

What is the default transformation of JSON and JS objects ?


Default transformation by AngularJS

1. Request configuration given as a JS object is auto-converted to JSON objects.
Example
$http({
       method: 'GET',
       url: 'EmployeeService/GetAllEmployees'
})

2. Similarly, A JSON response is auto-converted into a JS object.
Example
$http.get('EmployeeService/GetAllEmployees')
        .then( function(response) {
                   $scope.employees = response.data;
               } ,
function(reason) {
                   $scope.error = reason.data;
               } );


No comments:

Post a Comment

Note: only a member of this blog may post a comment.