Follow by Email

Tuesday, December 23, 2014

Calling a json rest api from angularJS || using AngularJS XMLHttpRequest to call service

hi lets see how to call a http rest api from angularjs

1. create the rest api which returns JSON data

2. Host the Http rest api ( in my case im hosting it on localhost )

3. Now we will see how to call this http api from angularjs


<!DOCTYPE html>


    <script src=""></script>


    <div ng-app="" ng-controller="EmpData">

        <div ng-repeat="x in Emp">
            <h1> {{ 'Employee ID:' + x.EID  }} </h1>
            <p>{{ 'Name: ' + x.EName}}</p>
            <p>{{ 'Salary: ' + x.ESalary}}</p>



        function EmpData($scope, $http) {
                success(function (data) {
                    $scope.Emp = data;



4. Output