angularjs ngTable -Custom filter template-calendar
jsp页面: <script type="text/ng-template" id="path/to/your/filters/top-Date-One.html">
<input type="text" ng-click="popup1.opened=!popup1.opened" uib-datepicker-popup="{{formats[2]}}" ng-model="vm.dateInfoOne" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" readonly class="form-control width-inherit" style="background-color: #fff"/>
</script>
<table ng-table="vm.tableParamsCompletedOrder" class="table table-condensed table-bordered table-striped">
<tr ng-repeat="order in $data">
<td title="'Date'" filter="{orderDate: 'path/to/your/filters/top-Date-One.html'}" sortable="'orderDate'">{{order.orderDate | date:'dd-MM-yyyy'}}</td>
<td title="'User Email'" filter="{userEmail: 'text'}" sortable="'userEmail'">{{order.userEmail}}</td>
<td title="'First Name'" filter="{firstName: 'text'}" sortable="'firstName'">{{order.firstName}}</td>
<td title="'Last Name'" filter="{lastName: 'text'}" sortable="'lastName'">{{order.lastName}}</td>
<td title="'Company'" filter="{companyName: 'text'}" sortable="'companyName'">{{order.companyName}}</td>
<td title="'Order Number'" filter="{orderCode: 'text' }" sortable="'orderCode'"><a href="#" data-ng-click="fn.openOrderInfo(order);">{{order.orderCode}}</a></td>
<td title="'Datasource'" filter="{datasource: 'text'}" sortable="'datasource'">{{order.datasource}}</td>
<td title="'Quantity'" filter="{quantity : 'text'}" sortable="'quantity'">{{order.quantity}}</td>
</tr>
</table> 其中 input是bootstrap中对应的日历控件
id="path/to/your/filters/top-Date-One.html" 对应 filter="{orderDate: 'path/to/your/filters/top-Date-One.html'}"
js:
angular.module("ni.controllers.user.reports", ["ngTable", "ngTableDemos", "angularMask"]);
angular.module("ni.controllers.user.reports").config(setConfigPhaseSettings);
setConfigPhaseSettings.$inject = ["ngTableFilterConfigProvider"];
function setConfigPhaseSettings(ngTableFilterConfigProvider) {
var filterAliasUrls = {
// note: ngTable also registers a 'number' filter
// we're overriding this alias to point to our custom template
};
ngTableFilterConfigProvider.setConfig({
aliasUrls: filterAliasUrls
});
// optionally set a default url to resolve alias names that have not been explicitly registered
// if you don't set one, then 'ng-table/filters/' will be used by default
ngTableFilterConfigProvider.setConfig({
defaultBaseUrl: "ng-table/filters/"
});
}
angularjs controller 中
//日历控件
$scope.popup1 = {
opened: false
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
};
$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd-MM-yyyy', 'shortDate'];
$scope.altInputFormats = ['M!/d!/yyyy'];
//ordersList post得到的结果集合
vm.tableParamsCompletedOrder = new NgTableParams({count: 15 }, {counts:[], dataset: ordersList });
//对于日历使用监听
$scope.$watch('vm.dateInfoOne',function(n,o){
if(n!=o && n != undefined && vm.status=="2,3,4"){
var temp;
temp= _.filter(vm.tempCompletedOrder,function(item){
return $filter('date')(n, 'yyyy-MM-dd')==$filter('date')(item.orderDate, 'yyyy-MM-dd');
});
vm.tableParamsCompletedOrder = new NgTableParams({count: 15, filter: vm.tableParamsCompletedOrder.filter()}, {counts:[], dataset: temp });
}else {
if (vm.tableParamsCompletedOrder != undefined) {
vm.tableParamsCompletedOrder = new NgTableParams({count: 15, filter: vm.tableParamsCompletedOrder.filter()}, {counts: [], dataset: vm.tempCompletedOrder});
}
}
})
其中
vm.tableParamsCompletedOrder.filter()是向vm.tableParamsCompletedOrder中增加之前的过滤条件
$filter('date')(item.orderDate, 'yyyy-MM-dd')将日期格式化,item.orderDate是字符戳的形式
具体参考http://ng-table.com/#/filtering/demo-custom-template
angularjs ngTable -Custom filter template-calendar的更多相关文章
- Part 13 Create a custom filter in AngularJS
Custom filter in AngularJS 1. Is a function that returns a function 2. Use the filter function to cr ...
- Angularjs 1 使用filter格式化输出href
Angularjs版本: 1.3.5 工作中,由于是多级菜单,如果上级菜单为空,就会访问Angularjs 默认的state,然后再展开菜单,我找资料之后,才知道是通过filter来格式化输出数据的, ...
- HTML5 & custom element & template
HTML5 & custom element & template template https://codepen.io/xgqfrms/pen/eYYExvp https://cs ...
- AngularJS学习--- AngularJS中的模板template和迭代器过滤filter step2 step3
1.AngularJS 模板---step2: mvc(Model-View-Controller)模式在后端用的比较多,在前端也是一样的常用; 在AngularJS中,一个视图是模型通过HTML模板 ...
- AngularJS 特性—SinglePage、template、Controller
单页Web应用(SinglePage) 顾名思义,只使用一个页面的Web应用程序.单页面应用是指用户通过浏览器加载独立的HTML页面,Ajax加载数据页面无刷新,实现操作各种操作. 模板(templa ...
- Angularjs ngTable使用备忘
项目中用到angularjs的表格ng-table,功能相当强大,像搜索.排序.checkbox.分页.每页表格显示数目等都有.API,demo什么的也只能参考官网了.这里做个备忘,哪天肯定还会用到. ...
- angularjs 指令详解 - template, restrict, replace
通过指令机制,angularjs 提供了一个强大的扩展系统,我们可以通过自定义指令来扩展自己的指令系统. 怎样定义自己的指令呢? 我们通过 Bootstrap UI来学习吧.这个项目使用 angula ...
- AngularJS学习--- 过滤器(filter),格式化要显示的数据 step 9
1.切换目录,启动项目 git checkout step- npm start 2.需求: 格式化要显示的数据. 比如要将true-->yes,false-->no,这样相互替换. 3. ...
- 详解AngularJS中的filter过滤器用法
系统的学习了一下angularjs,发现angularjs的有些思想根php的模块smarty很像,例如数据绑定,filter.如果对smarty比较熟悉的话,学习angularjs会比较容易一点.这 ...
随机推荐
- MySQL FEDERATED引擎使用示例, 类似Oracle DBLINK
原文地址:http://it.dataguru.cn/article-3352-1.html 摘要: 本地MySQL数据库要访问远程MySQL数据库的表中的数据, 必须通过FEDERATED存储引擎来 ...
- Keil 的辅助工具和部份高级技巧
在前面的几讲中我们介绍了工程的建立方法,常用的调试方法,除此之外,Keil 还提供 了一些辅助工具如外围接口.性能分析.变量来源分析.代码作用分析等,帮助我们了解程 的性能.查找程序中的隐藏错误,快速 ...
- QT5.1.1中MinGW4.8的环境变量配置
1.右击“我的电脑”图标,在弹出的菜单上选择“属性(R)”菜单项. 2.选择“高级”选项卡.点击“环境变量”按钮. 3.点击“新建(W)”按钮,新建环境变量:MINGW_HOME,变量值为MinGW的 ...
- 显示 SQLite 日志
通过在 Logcat 查看 SQL 执行语句可以帮助你调试 SQLite 问题, 使用 ADB SHELL 执行如下命令即可在 Logcat 输出 SQL 执行日志: adb shell setpro ...
- WPF Application 执行顺序
public static void Main() { ApplicationClass.App app = new ApplicationClass.App();app.InitializeComp ...
- Spring - Web MVC简介
Web MVC简介 1.1.Web开发中的请求-响应模型: 在Web世界里,具体步骤如下: 1. Web浏览器(如IE)发起请求,如访问http://www.cnblogs.com 2. Web服 ...
- dede织梦跨频道调用指定栏目文章的解决方法
很久没有写技术类的文章了,这次这个标题写的- 呃, 有一点儿纠结. 事情是这样的,刚刚回答了一个百度问答上的问题,这个问题的大体意思是,有一个图片栏目,内含3个子栏目,分别为图片栏目1.2和3,另有三 ...
- Unity Flow distort of screen
Shader "ScreenWater" {Properties { _MainTex ("Base (RGB)", 2D) = "white&quo ...
- Bzoj 2038: [2009国家集训队]小Z的袜子(hose) 莫队,分块,暴力
2038: [2009国家集训队]小Z的袜子(hose) Time Limit: 20 Sec Memory Limit: 259 MBSubmit: 5763 Solved: 2660[Subm ...
- oracle 创建表空间、创建用户管理该表空间
/*分为四步 *//*第1步:创建临时表空间 */create temporary tablespace user_temp tempfile 'D:\oracle\oradata\Oracle9 ...