pTutorial

New way to learn Programming

Angularjs get data from database

AngularJS get data from php with bootstrap

AngularJS get data from database: AngularJS get data from database using ng-repeat and $http.get. Using the following code you can get the data from database using any server side programming language like PHP, Java, Node.js etc and render on HTML page. This example is based on the PHP.

HTML

<!DOCTYPE html>
<html>
<head>
<script src = "http://www.ptutorial.com/angularjs/
angular.min.js"></script>
<link href="http://freeonlinecompiler.ptutorial.com/
css/bootstrap.min.css" rel="stylesheet"  >
</head>
<body>
<div ng-app="ukApp" ng-controller="myCtrl">
<div class="container">

<table class="table">
    <thead>
      <tr class="danger" >
        <th>ID</th>
        <th>Country Name</th>
        <th>Static Data</th>
      </tr>
    </thead>
    <tbody>
      <tr class="success" ng-repeat="x in tempData">
        <td>{{x.id}}</td>
        <td>{{x.name}}</td>
        <td>done</td>
      </tr>
    </tbody>
  </table>
</div>
</div>

</div>
</body>
</html>

AngularJS get data from api


<script>
var app = angular.module('ukApp', []);
app.controller('myCtrl', function ($scope, $http) {
$http.get("db.php")
.success(function (response) {
$scope.tempData = response;
});
}

});
</script> 

Download

See Also


QUOTES OF THE DAY

Impossible is a word only be found in the dictionary of fools.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER