Angular.JS讀取數(shù)據(jù)庫(kù)數(shù)據(jù)調(diào)用完整實(shí)例
本文實(shí)例講述了Angular.JS讀取數(shù)據(jù)庫(kù)數(shù)據(jù)調(diào)用。分享給大家供大家參考,具體如下:
以下是實(shí)例代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<style>
table{position:relative;}
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 10px 20px;
}
table tr:nth-child(odd) {
background-color: #f1f1f1;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
i{display:block;background:url(buffer.gif) no-repeat;position:absolute;left:50%;margin-left:-16px;top:50px;width:32px;height:32px;}
</style>
</head>
<body>
<center style="margin-top:100px;">
<div ng-app="myApp" ng-controller="customersCtrl">
<h3>數(shù)據(jù)統(tǒng)計(jì)</h3>
<table>
<tr>
<th>活動(dòng)編號(hào)</th>
<th>活動(dòng)名稱</th>
<th>點(diǎn)擊量</th>
<th>最后訪問時(shí)間<i id="buffer"></i></th>
<th>所屬欄目</th>
</tr>
<tr ng-repeat="x in names">
<td>{{ x.sid }} </td> <!--活動(dòng)編號(hào)-->
<td>{{ x.sname }} </td> <!--活動(dòng)名稱-->
<td>{{ x.sclick }} 次</td> <!--點(diǎn)擊量-->
<td>{{ x.stime | date:'yyyy-MM-dd HH:mm:ss' }}</td> <!--最后訪問時(shí)間-->
<td>{{ x.sproject }}</td> <!--所屬欄目-->
</tr>
</table>
</div>
</center>
<script>
var buffer = document.getElementById("buffer");
buffer.style.display = 'block';
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("Customers_MySQL.php")
.success(function (response) {
$scope.names = response;
buffer.style.display = 'none'; //成功調(diào)取數(shù)據(jù)之后
});
//成功調(diào)取mysql數(shù)據(jù),將response.records改為response,因?yàn)樗莻€(gè)對(duì)象
});
</script>
</body>
</html>
更多關(guān)于AngularJS相關(guān)內(nèi)容可查看本站專題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門與進(jìn)階教程》及《AngularJS MVC架構(gòu)總結(jié)》
希望本文所述對(duì)大家AngularJS程序設(shè)計(jì)有所幫助。
- AngularJS實(shí)現(xiàn)分頁(yè)顯示數(shù)據(jù)庫(kù)信息
- Angular.JS內(nèi)置服務(wù)$http對(duì)數(shù)據(jù)庫(kù)的增刪改使用教程
- 三種AngularJS中獲取數(shù)據(jù)源的方式
- AngularJS實(shí)現(xiàn)數(shù)據(jù)列表的增加、刪除和上移下移等功能實(shí)例
- 基于AngularJS實(shí)現(xiàn)頁(yè)面滾動(dòng)到底自動(dòng)加載數(shù)據(jù)的功能
- Angularjs實(shí)現(xiàn)多個(gè)頁(yè)面共享數(shù)據(jù)的方式
- 詳解angularJs中自定義directive的數(shù)據(jù)交互
- Angular.js如何從PHP讀取后臺(tái)數(shù)據(jù)
- Angularjs 滾動(dòng)加載更多數(shù)據(jù)
- 深入學(xué)習(xí)AngularJS中數(shù)據(jù)的雙向綁定機(jī)制
- 在 Angular6 中使用 HTTP 請(qǐng)求服務(wù)端數(shù)據(jù)的步驟詳解
相關(guān)文章
深入探究AngularJs之$scope對(duì)象(作用域)
本篇文章主要介紹了深入探究AngularJs之$scope對(duì)象(作用域),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
angular 用Observable實(shí)現(xiàn)異步調(diào)用的方法
這篇文章主要介紹了angular 用Observable實(shí)現(xiàn)異步調(diào)用的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-12-12
Angular利用內(nèi)容投射向組件輸入ngForOf模板的方法
本篇文章主要介紹了Angular利用內(nèi)容投射向組件輸入ngForOf模板的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-03-03
詳解Angular的數(shù)據(jù)顯示優(yōu)化處理
本文主要對(duì)Angular的數(shù)據(jù)顯示優(yōu)化處理進(jìn)行詳細(xì)介紹,具有一定的參考價(jià)值,下面跟著小編一起來看下吧2016-12-12
使用Angular CLI進(jìn)行Build(構(gòu)建)和Serve詳解
這篇文章主要介紹了使用Angular CLI進(jìn)行Build(構(gòu)建)和Serve詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-03-03
AngularJS中重新加載當(dāng)前路由頁(yè)面的方法
下面小編就為大家分享一篇AngularJS中重新加載當(dāng)前路由頁(yè)面的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-03-03
Angular2中constructor和ngOninit的使用講解
這篇文章主要介紹了Angular2中constructor和ngOninit的使用講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-05-05

