anjular.js读取数据库数据调用实例

以下是实例代码:

<!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>数据统计</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.id }} </td>     <!--编号-->
    <td>{{ x.name }} </td>   <!--名称-->  
    <td>{{ x.click }} 次</td>   <!--点击-->
    <td>{{ x.time | date:'yyyy-MM-dd HH:mm:ss' }}</td>   <!--时间-->
    <td>{{ x.cate}}</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("数据接口地址")
    .success(function (response) {
    		$scope.names = response; 
    		buffer.style.display = 'none';    
    });
});


</script>

</body>
</html>

注:有连接外部地址,时间久远的缘故,可能已经失效。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

任聪聪

创作不易,你的打赏是我的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值