✔ AngularJS SQL
> AngularJS는 DB에 있는 데이터를 표현하는데 아주 적합하다. 근데 그 데이터가 JSON 형식이어야한다
1. Fetching Data From a PHP Server Running MySQL
<div ng-app="myApp" ng-controller="customerCtrl">
<table>
<tr ng-repeat="x in names">
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http){
$http.get("custoerms_mysql.php").then(function(response){
$scope.names = response.data.records;
});
});
</script>
2. Fetching Data From an ASP.NET Server Running SQL
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr ng-repeat="x in names">
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http){
$http.get("customers_sql.aspx").then(function(response){
$scope.names = response.data.records'
});
});
</script>
** 위 글은 w3schools.com에 있는 내용을 한국어로 번역하여 적어둔 글입니다.
- https://www.w3schools.com/angular/angular_sql.asp
728x90
'IT' 카테고리의 다른 글
AngularJS #17 - Events (0) | 2022.01.03 |
---|---|
AngularJS #16 - HTML DOM (0) | 2022.01.02 |
AngularJS #14 - Select Boxes (0) | 2022.01.01 |
AngularJS #13 - Tables (0) | 2021.12.27 |
AngularJS #12 - Ajax($http) (0) | 2021.12.27 |