pTutorial

New way to learn Programming

AngularJS Get Data from Server

AngularJS Get Example

The $http service is a core Angular service that provide the facility to communication with the remote HTTP servers via the browser's XMLHttpRequest object. See the following example below.

HTMl for get

<!DOCTYPE html>
<html>
<head>
<script src = "http://www.ptutorial.com/angularjs/
angular.min.js"></script>

<style>
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 15px;
}
</style>

</head>
<body>

<div ng-app="ukApp" ng-controller="ukController"> 
 
<table>
<tr>
<th>Name</th>
<th>City</th>
</tr>
  <tr ng-repeat="x in names">
    <td>{{ x.Name }}</td>
    <td>{{ x.City }}</td>
  </tr>
</table>
 
</div>
 
</body>
</html>

AngularJS get json data Example

<script>
var app = angular.module('ukApp', []);
app.controller('ukController', function($scope, $http) {
    $http.get("data.php")
    .success(function (response) {$scope.names = response.records;});
});
</script>

Download

See Also


QUOTES OF THE DAY

Knowledge itself is a power.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER