Angualrjs和bootstrap相結(jié)合實現(xiàn)數(shù)據(jù)表格table
AngularJS的數(shù)據(jù)表格
需要使用angualarjs、bootstrap、dirPagination.js
效果圖:

1.html部分
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app="app">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>angularjs的數(shù)據(jù)表格</title>
<link rel="stylesheet" href="css/bootstrap-3.0.0/css/bootstrap.css" rel="external nofollow" />
<link href="css/special.css" rel="external nofollow" rel="stylesheet" />
<script src="js/angular-1.3.0.js"></script>
<script src="vendor/dirPagination.js"></script>
<script src="js/app/angularjsTable.js"></script>
</head>
<body>
<form ng-controller="tableCtrl as aly">
<div class="sp-page-content">
<div class="sp-page-title">
angularjs的數(shù)據(jù)表格
</div>
<table class="sp-grid">
<thead>
<tr>
<th style="width: 20%;">應(yīng)用代碼</th>
<th style="width: 20%;">應(yīng)用名稱</th>
<th style="width: 20%;">版本</th>
<th style="width: 20%;">狀態(tài)</th>
<th style="width: 20%;">操作</th>
</tr>
</thead>
<tbody id="myApplyTable">
<tr ng-show="aly.users.length <= 0">
<td colspan="5" style="text-align: center;">還沒有數(shù)據(jù)</td>
</tr>
<tr dir-paginate="user in aly.users|itemsPerPage:aly.itemsPerPage" total-items="aly.total_count">
<td>{{user.code}}</td>
<td>{{user.name}}</td>
<td>{{user.version}}</td>
<td>{{user.status}}</td>
<td>
<a class="sp-color-blue">安 裝</a>|
<a class="sp-color-green">查 看</a>
</td>
</tr>
<!--<tr>
<td>asd1234ddd</td>
<td>員工管理</td>
<td>v2.0.1</td>
<td>已啟用</td>
<td><a ui-sref="app.apply_view" class="ligblue">查 看</a></td>
</tr>-->
</tbody>
</table>
<dir-pagination-controls max-size="8"
direction-links="true"
boundary-links="true"
on-page-change="aly.getData(newPageNumber)">
</dir-pagination-controls>
</div>
</form>
</body>
</html>
2.angularjsTable.js部分
'use strict';
var app = angular.module('app', [
'angularUtils.directives.dirPagination'
]);
app.controller('tableCtrl', ['$http', function ($http) {
var self = this;
//數(shù)據(jù)表格的控制器,動態(tài)加載table表格數(shù)據(jù)
self.users = []; //declare an empty array
self.pageno = 1; // initialize page no to 1
self.total_count = 0;
self.itemsPerPage = 10; //this could be a dynamic value from a drop down
self.getData = function (pageno) { // This would fetch the data on page change.
//In practice this should be in a factory.
self.pageno = pageno;
self.users = [];
$http({
method: 'get',
url: 'json/myApply.txt',
data: { pagesize: self.itemsPerPage, pageno: self.pageno }
}).success(function (response) {
self.users = response.data; //ajax request to fetch data into self.data
self.total_count = response.total_count;
});
};
self.getData(self.pageno);
//數(shù)據(jù)表格的控制器 end
}]);
3.json數(shù)據(jù)部分 myApply.txt
{
"data":[
{
"id":"1",
"code":"dheu22102d",
"name":"項目管理",
"version":"v1.0.1",
"status":"未啟用"
},
{
"id":"2",
"code":"asd1234ddd",
"name":"員工管理",
"version":"v2.0.1",
"status":"已啟用"
}
],
"total_count": 22
}
以上所述是小編給大家介紹的Angualrjs和bootstrap相結(jié)合實現(xiàn)數(shù)據(jù)表格table,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- 在Bootstrap開發(fā)框架中使用dataTable直接錄入表格行數(shù)據(jù)的方法
- Bootstrap table表格初始化表格數(shù)據(jù)的方法
- BootStrap Fileinput插件和Bootstrap table表格插件相結(jié)合實現(xiàn)文件上傳、預(yù)覽、提交的導(dǎo)入Excel數(shù)據(jù)操作步驟
- bootstrap table 數(shù)據(jù)表格行內(nèi)修改的實現(xiàn)代碼
- bootstrap jquery dataTable 異步ajax刷新表格數(shù)據(jù)的實現(xiàn)方法
- Bootstrap Table表格一直加載(load)不了數(shù)據(jù)的快速解決方法
- bootstrap-table獲取表格數(shù)據(jù)的多種方式
相關(guān)文章
AngularJS的依賴注入實例分析(使用module和injector)
這篇文章主要介紹了AngularJS的依賴注入,結(jié)合實例形式分析了依賴注入的原理及使用module和injector實現(xiàn)依賴注入的步驟與操作技巧,需要的朋友可以參考下2017-01-01
Angular 2應(yīng)用的8個主要構(gòu)造塊有哪些
這篇文章主要為大家詳細(xì)介紹了Angular 2應(yīng)用的8個主要構(gòu)造塊,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-10-10
Angular學(xué)習(xí)筆記之a(chǎn)ngular的$filter服務(wù)淺析
本文是小編記錄的angular學(xué)習(xí)筆記,通過本文首先給大家介紹了$filter服務(wù),然后介紹下內(nèi)置filter及filter的簡單使用,非常不錯具有參考借鑒價值,感興趣的朋友一起看看吧2016-11-11
Angular2 PrimeNG分頁模塊學(xué)習(xí)
這篇文章主要為大家詳細(xì)介紹了Angular2 PrimeNG分頁模塊學(xué)習(xí)教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-01-01
Angular2 Service實現(xiàn)簡單音樂播放器服務(wù)
本篇文章主要介紹了Angular2 Service實現(xiàn)簡單音樂播放器服務(wù) ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-02-02
ios設(shè)備中angularjs無法改變頁面title的解決方法
今天小編就為大家分享一篇ios設(shè)備中angularjs無法改變頁面title的解決方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09
Angular.js實現(xiàn)動態(tài)加載組件詳解
這篇文章主要給大家介紹了關(guān)于Angular.js實現(xiàn)動態(tài)加載組件的相關(guān)資料,文中介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。2017-05-05

