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)名稱(chēng)</th>
<th>點(diǎn)擊量</th>
<th>最后訪(fǎng)問(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)名稱(chēng)-->
<td>{{ x.sclick }} 次</td> <!--點(diǎn)擊量-->
<td>{{ x.stime | date:'yyyy-MM-dd HH:mm:ss' }}</td> <!--最后訪(fǎng)問(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)于A(yíng)ngularJS相關(guān)內(nèi)容可查看本站專(zhuān)題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門(mén)與進(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í)例
- 基于A(yíng)ngularJS實(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)文章
angular4自定義表單控件[(ngModel)]的實(shí)現(xiàn)
這篇文章主要介紹了angular4自定義表單控件[(ngModel)]的實(shí)現(xiàn),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-11-11
Angular 4.x中表單Reactive Forms詳解
這篇文章主要介紹了Angular 4.x中表單Reactive Forms的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),相信對(duì)大家具有一定的參考價(jià)值,需要的朋友們下面來(lái)一起看看吧。2017-04-04
AngularJS基礎(chǔ) ng-non-bindable 指令詳細(xì)介紹
本文主要講解AngularJS ng-non-bindable 指令,這里幫大家整理了ng-non-bindable指令的基本知識(shí)資料,有需要的小伙伴可以參考下2016-08-08
深入學(xué)習(xí)JavaScript的AngularJS框架中指令的使用方法
這篇文章主要介紹了深入學(xué)習(xí)JavaScript的AngularJS框架中指令的使用方法,指令的使用是Angular入門(mén)學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2016-03-03
anime.js 實(shí)現(xiàn)帶有描邊動(dòng)畫(huà)效果的復(fù)選框(推薦)
anime.js是一個(gè)靈活的輕型JavaScript動(dòng)畫(huà)庫(kù)。這篇文章主要介紹了anime.js 實(shí)現(xiàn)帶有描邊動(dòng)畫(huà)效果的復(fù)選框 ,需要的朋友可以參考下2017-12-12
AngularJS全局警告框?qū)崿F(xiàn)方法示例
這篇文章主要介紹了AngularJS全局警告框?qū)崿F(xiàn)方法,結(jié)合實(shí)例形式分析了AngularJS全局警告框的實(shí)現(xiàn)步驟與相關(guān)操作技巧,需要的朋友可以參考下2017-05-05

