今天实现一个分页控件,效果如下:

1、HTML:

 <!doctype html>
 <!--suppress ALL -->
 <html ng-app="appTow">
 <head>
     <meta http-equiv="content-type" content="text/html;charset=utf-8">
     <meta content="always" name="referrer">
     <script src="angular.min.js"></script>
     <script src="./Script/jquery-2.1.1.min.js"></script>
     <link href="./Content/Plus/bootstrap-3.2.0-dist/css/bootstrap.min.css" rel="stylesheet"/>
     <script src="./Content/Plus/bootstrap-3.2.0-dist/js/bootstrap.min.js"></script>
     <link href="./Skin/Default/css/site.css" rel="stylesheet"/>
     <script src="app.js"></script>
 </head>
 <body>
 <div ng-controller="MyController">
     Your name:
     <input type="text" ng-model="username">
     <button ng-click='sayHello()'>greet</button>
     <hr>
     {{greeting}}
 </div>
 <div ng-controller="MyController1">
     Your name:
     <input type="text" ng-model="username">
     <button ng-click='sayHello()'>greet</button>
     <li ng-repeat="x in names" ng-click="clickOneLi(x.Name,$index)">
         {{ x.Name}}
     </li>
     <table>
         <tr>
             <td class="ruyeeTableTDLable"><span>Names</span></td>
             <td class="ruyeeTableDataCell">
                 <div class="btn-group">
                     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                             aria-expanded="false">
                         <span>{{selectedItem}}</span><span class="caret"></span>
                     </button>
                     <ul class="dropdown-menu" role="menu">
                         <li ng-repeat="x in names">
                             <a href="#" ng-click="clickOneLi(x.Name,$index)">{{ x.Name}}</a>
                         </li>
                     </ul>
                 </div>
             </td>
         </tr>
     </table>

     <button ng-click='modal_showModal()'>showModal</button>
     <div class='modal fade'
          tabindex='-1'
          role='dialog'
          aria-labelledby='myModalLabel'
          aria-hidden='true'
          id="myModal">
         <div class='modal-dialog'>
             <div class='modal-content'>
                 <div class='modal-header'>
                     <button type='button' class='close' data-dismiss='modal'>
                         <span aria-hidden='true'>&times;</span>
                         <span class='sr-only'>关闭</span></button>
                     <h4 class='modal-title' id='myModalLabel'>
                         <span>系统提示</span>
                     </h4>
                 </div>
                 <div class='modal-body'>
                     <span>{{modal_selectedId}}:{{selectedItem}}</span>
                 </div>
                 <div class='modal-footer'>
                     <button type='button' data-dismiss='modal' class='btn btn-primary'>
                         取消
                     </button>
                     <button type='button' data-dismiss='modal' class='btn btn-primary'
                             ng-click='modal_okAction(modal_selectedId)'>
                         确定
                     </button>
                 </div>
             </div>
         </div>
     </div>
     <div class="row">
         <div class="btn-toolbar" role="toolbar">
             <div class="btn-group">
                 <input class="btn btn-success pageBtn" type="button" value="<" ng-click="perPageClick()"/>
             </div>
             <div class="btn-group">
                 <input "/>
             </div>
             <div class="btn-group">
                 <button ng-repeat="x in btns" class="btn btn-success pageBtn" type="button"
                         ng-click="$parent.btnClick(x.data)">
                     {{x.data}}
                 </button>

             </div>
             <div class="btn-group">
                 <button class="btn btn-success pageBtn" type="button" ng-click="lastPageClick()">
                     {{pageTotal}}
                 </button>
             </div>
             <div class="btn-group">
                 <input class="btn btn-success pageBtn" type="button" value=">" ng-click="nextPageClick()"/>
             </div>
             <div class="btn-group">
                 <span class="badge">{{totalCount}}</span>
             </div>
         </div>

     </div>
 </div>
 </div>
 </body>
 </html>

2、JS:

 // modal窗体封装
 function modalWindow(angularObj, modalId, okAction) {
     angularObj.modal_selectedId = "-1";
     angularObj.modal_showModal = function () {
         $('#' + modalId).modal();
     }
     angularObj.modal_okAction = function (item) {
         if (typeof okAction == 'function')
             okAction(item);
     }
 }

 function pagedButtons(self) {

     self.totalCount = 100;
     self.perCount = 10;
     self.pageIndex = 1;
     self.btns = [{"data":"1"},{"data":"2"},{"data":"3"}];
     self.pageTotal=10;
     self.getData=function(wantIndex)
     {
         console.log("wantIndex>>"+wantIndex)
     }
     self.btnClick=function(item){
         self.getData(item);
     }

     self.perPageClick = function () {
         var wantIndex = self.pageIndex - 1;
         if (wantIndex <= 0) return;
         self.getData(wantIndex);
     }
     self.nextPageClick = function () {
         var wantIndex = self.pageIndex + 1;
         if (wantIndex - 1 > (self.totalCount / self.perCount)) return;
         self.getData(wantIndex);
     }
     self.firstPageClick = function () {
         self.getData(1);
     }
     self.lastPageClick = function () {
         self.getData(self.pageTotal);
     }

 }
 angular.module('appOne', [])
     .controller('MyController',
     function ($scope) {
         $scope.username = 'World';
         $scope.sayHello = function () {
             $scope.greeting = 'Hello ' + $scope.username + '!';
         };
     });
 angular.module('appTow', ['appOne'])
     .controller('MyController1',
     function ($scope, $http) {
         $scope.username = 'World002';
         $scope.sayHello = function () {
             $http.get("Data.json")
                 .success(function (response) {
                     $scope.names = response;
                 });
         };
         $scope.clickOneLi = function (item, index) {
             $scope.selectedItem = item;

             $scope.modal_selectedId = index;
             $('#myModal').modal();

         }
         $scope.selectedItem = "Please select one";
         /*region modal窗体*/
         /*
          // modal窗体简单实现
          $scope.modal_selectedId="-1";
          $scope.modal_showModal=function(){
          $('#myModal').modal();
          }
          $scope.modal_okAction=function(id)
          {
          alert(id);
          }
          */
         $scope.cc="cc";
         pagedButtons($scope);
         modalWindow($scope, 'myModal', function (_) {
             alert(_);
         })

         /*endregion modal窗体*/
     });

angular+bootstrap+MVC 之三,分页控件初级版的更多相关文章

  1. 基于KO+bootstrap+MVC的分页控件

    JS: /// <reference path="../knockout-3.2.0.js" /> var ViewModel = function (data) { ...

  2. 基于存储过程的MVC开源分页控件--LYB.NET.SPPager

    摘要 现在基于ASP.NET MVC的分页控件我想大家都不陌生了,百度一下一大箩筐.其中有不少精品,陕北吴旗娃杨涛大哥做的分页控件MVCPager(http://www.webdiyer.com/)算 ...

  3. 一个Bootstrap风格的分页控件

      http://www.cnblogs.com/wangwei123/p/3682626.html 主题 jQueryBootstrap 一个Bootstrap风格的分页控件,对于喜欢Bootstr ...

  4. 基于存储过程的MVC开源分页控件

    基于存储过程的MVC开源分页控件--LYB.NET.SPPager 摘要 现在基于ASP.NET MVC的分页控件我想大家都不陌生了,百度一下一大箩筐.其中有不少精品,陕北吴旗娃杨涛大哥做的分页控件M ...

  5. Mvc自定义分页控件

    MVC开发分页常常使用第三方控件,生成的分页HTML带有版权申明,虽然免费,但是总有的别扭.于是,某日,楼主闲来蛋疼,折腾了个自定义分页控件: 先来展示下效果图: 1>当分页不超过10页的时候, ...

  6. Net MVC轻量级分页控件

    JPager.Net MVC超好用轻量级分页控件   JPager.Net  MVC好用的轻量级分页控件,好用到你无法想象,轻量到你无法想象. JPager.Net  MVC好用的轻量级分页控件,实现 ...

  7. MVC Page分页控件

    MVCPage帮助类 控制器代码 public ActionResult Article(int? page) { //Session["ArticleClass"] = cont ...

  8. 使用 Vue.js 结合bootstrap 实现的分页控件

    原文链接:http://blog.csdn.net/qiuhaotc/article/details/53031884 源码下载: http://pan.baidu.com/s/1i4XgH6H 密码 ...

  9. MvcPager分页控件以适用Bootstrap

    随笔- 9  文章- 0  评论- 33  修改MvcPager分页控件以适用Bootstrap 效果(含英文版,可下载)   软件开发分页效果必不可少,对于Asp.Net MVC 而言,MvcPag ...

随机推荐

  1. Caché数据库学习笔记(4)

    目录 DeepSee的使用 数据.方法等的导入与导出 ======================================================== ================ ...

  2. 关于JAVA EE项目在WEB-INF目录下的jsp页面如何访问WebRoot中的CSS和JS文件

    找了这么久资料,总算解决了 感谢博客园:http://www.cnblogs.com/xsht/p/5275081.html 感谢百度:http://zhidao.baidu.com/link?url ...

  3. 无法嵌入互操作类型“Microsoft.Office.Interop.Excel.ApplicationClass”。请改用适用的接口

    解决 把Microsoft.Office.Interop.Excel.DLL的嵌入互操作类型改为ture就可以了

  4. PHP自动发邮件

    自动发邮件 使用了这个类http://bbs.php100.com/read-htm-tid-121431.html 因他用的php版本较老,用到了函数ereg_replace() 和 ereg() ...

  5. SqlParameter设定value为0却变成null

    直接MSDN:http://msdn.microsoft.com/zh-cn/library/0881fz2y(VS.80).aspx 当在 value 参数中指定 Object 时,SqlDbTyp ...

  6. .htaccess的301重定向代码

    把不带www的域名301到带www的域名 RewriteEngine On RewriteCond %{http_host} ^example.com$ [NC] RewriteRule ^(.*)$ ...

  7. bzoj 2761: [JLOI2011]不重复数字

    #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #d ...

  8. CSipSimple结构浅析

    最近做一个VOIP的项目,调研了CSipSimple.都说CSipSimple结构清晰,但是代码下下来看了一下,还是一头雾水,不知从何看起.于是想到从最简单的打电话开始,借助网上一篇博文"C ...

  9. MS Sql server 2008 学习笔记

    数据库中常用的概念 Sql本身是一个服务器,没有界面,Management Studio  只是一个SQL Server管理工具而已,不是服务器. Sql server 在管理工具下面的服务SQL S ...

  10. json体会

    1.用json-lib的jar包,创建JsonObject的对象(其引用取名jo),JsonObject jo = new JsonObject(); 再创建一个jsonobject对象:JsonOb ...