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会比较容易一点.这 ...
随机推荐
- 【转】iOS 开发怎么入门?
原文网址:http://www.zhihu.com/question/20264108 iOS 开发怎么入门? 请问有设计模式.内存管理方面的资料吗?最好有除了官方文档之外的其它内容,10 条评论 分 ...
- (转载)mysql group by 用法解析(详细)
(转载)http://blog.tianya.cn/blogger/post_read.asp?BlogID=4221189&PostID=47881614 mysql distinct 去重 ...
- HDU 5927 Auxiliary Set 【DFS+树】(2016CCPC东北地区大学生程序设计竞赛)
Auxiliary Set Time Limit: 9000/4500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- HDU-4974 A simple water problem
http://acm.hdu.edu.cn/showproblem.php?pid=4974 话说是签到题,我也不懂什么是签到题. A simple water problem Time Limit: ...
- LoadRunner的场景设置
loadrunner场景设置的方法: 1.逐步增加用户数,分多次去运行场景.比如:第一次运行50并发,第二次运行100并发…… 2.针对同一个脚本设置多个组,使用组策略(点击Edit Schedule ...
- [IoLanguage]Io Tutorial[转]
Io Tutorial Math Io> 1+1 ==> 2 Io> 2 sin ==> 0.909297 Io> 2 sqrt ==> 1.414214 ...
- POJ 1775 (ZOJ 2358) Sum of Factorials
Description John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, was a Hungarian-American mathematic ...
- spring maven pom
https://spring.io/blog/2009/12/02/obtaining-spring-3-artifacts-with-maven/
- Ehcache简单说明及使用
EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点,是Hibernate中默认的CacheProvider. Ehcache是一种广泛使用的开源Java分布式缓存.主要面向通用缓存 ...
- SQL profile纵览(10g)
第一篇:介绍 10g开始,查询优化器(Query optimizer)扩展成自动调整优化器(Automatic Tuning Optimizer).也就是扩展了功能.此时,我们就可以让 ...