Angular.JS讀取數(shù)據(jù)庫數(shù)據(jù)調(diào)用完整實例
本文實例講述了Angular.JS讀取數(shù)據(jù)庫數(shù)據(jù)調(diào)用。分享給大家供大家參考,具體如下:
以下是實例代碼:
<!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)計</h3> <table> <tr> <th>活動編號</th> <th>活動名稱</th> <th>點擊量</th> <th>最后訪問時間<i id="buffer"></i></th> <th>所屬欄目</th> </tr> <tr ng-repeat="x in names"> <td>{{ x.sid }} </td> <!--活動編號--> <td>{{ x.sname }} </td> <!--活動名稱--> <td>{{ x.sclick }} 次</td> <!--點擊量--> <td>{{ x.stime | date:'yyyy-MM-dd HH:mm:ss' }}</td> <!--最后訪問時間--> <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,因為它是個對象 }); </script> </body> </html>
更多關(guān)于AngularJS相關(guān)內(nèi)容可查看本站專題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門與進階教程》及《AngularJS MVC架構(gòu)總結(jié)》
希望本文所述對大家AngularJS程序設(shè)計有所幫助。
- AngularJS實現(xiàn)分頁顯示數(shù)據(jù)庫信息
- Angular.JS內(nèi)置服務(wù)$http對數(shù)據(jù)庫的增刪改使用教程
- 三種AngularJS中獲取數(shù)據(jù)源的方式
- AngularJS實現(xiàn)數(shù)據(jù)列表的增加、刪除和上移下移等功能實例
- 基于AngularJS實現(xiàn)頁面滾動到底自動加載數(shù)據(jù)的功能
- Angularjs實現(xiàn)多個頁面共享數(shù)據(jù)的方式
- 詳解angularJs中自定義directive的數(shù)據(jù)交互
- Angular.js如何從PHP讀取后臺數(shù)據(jù)
- Angularjs 滾動加載更多數(shù)據(jù)
- 深入學(xué)習(xí)AngularJS中數(shù)據(jù)的雙向綁定機制
- 在 Angular6 中使用 HTTP 請求服務(wù)端數(shù)據(jù)的步驟詳解
相關(guān)文章
angular 用Observable實現(xiàn)異步調(diào)用的方法
這篇文章主要介紹了angular 用Observable實現(xiàn)異步調(diào)用的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12Angular利用內(nèi)容投射向組件輸入ngForOf模板的方法
本篇文章主要介紹了Angular利用內(nèi)容投射向組件輸入ngForOf模板的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03詳解Angular的數(shù)據(jù)顯示優(yōu)化處理
本文主要對Angular的數(shù)據(jù)顯示優(yōu)化處理進行詳細(xì)介紹,具有一定的參考價值,下面跟著小編一起來看下吧2016-12-12使用Angular CLI進行Build(構(gòu)建)和Serve詳解
這篇文章主要介紹了使用Angular CLI進行Build(構(gòu)建)和Serve詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03Angular2中constructor和ngOninit的使用講解
這篇文章主要介紹了Angular2中constructor和ngOninit的使用講解,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-05-05