Angular.JS讀取數(shù)據(jù)庫(kù)數(shù)據(jù)調(diào)用完整實(shí)例

本文實(shí)例講述了Angular.JS讀取數(shù)據(jù)庫(kù)數(shù)據(jù)調(diào)用。分享給大家供大家參考,具體如下:

專注于為中小企業(yè)提供成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)東光免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上1000+企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

以下是實(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 >
<div ng-app="myApp" ng-controller="customersCtrl">
<h4>數(shù)據(jù)統(tǒng)計(jì)</h4>
<table>
 <tr>
  <th>活動(dòng)編號(hào)</th>
  <th>活動(dòng)名稱</th>
  <th>點(diǎn)擊量</th>
  <th>最后訪問(wèn)時(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>  <!--最后訪問(wèn)時(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入門(mén)與進(jìn)階教程》及《AngularJS MVC架構(gòu)總結(jié)》

希望本文所述對(duì)大家AngularJS程序設(shè)計(jì)有所幫助。

當(dāng)前名稱:Angular.JS讀取數(shù)據(jù)庫(kù)數(shù)據(jù)調(diào)用完整實(shí)例
本文網(wǎng)址:http://muchs.cn/article24/ipijje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、品牌網(wǎng)站制作、企業(yè)建站小程序開(kāi)發(fā)、網(wǎng)站營(yíng)銷域名注冊(cè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司