angularjs自定义过滤器手机号加星
2018-03-19 08:56
447 查看
本代码转自向军老师的angularjs课程
<!DOCTYPE html> <html lang="en" ng-app="hd"> <head> <title></title> <script type="text/javascript" src="js/angular-1.3.0.js"></script> <script type="text/javascript" src="js/jquery.js"></script> </head> <body> <div ng-controller="ctrl"> <table border="1" width="600"> <tr> <td>编号</td> <td>姓名</td> <td>手机号</td> </tr> <tr ng-repeat = "(k,v) in data"> <td>{{v.id}}</td> <td>{{v.name}}</td> <td>{{v.mobile | truncate:6}}</td> </tr> </table> </div> <script type="text/javascript"> var m = angular.module('hd',[]); m.filter('truncate',function(){ return function(mobile,len){ len = len?len:3; return mobile.substr(0,11-len)+new String('*').repeat(len); } }); m.controller('ctrl',['$scope','$http','$filter',function($scope,$http,$filter){ $scope.data = [ {id:1,name:'刘畅',mobile:'13544664646'}, {id:2,name:'王桢',mobile:'13589898989'}, {id:3,name:'梁志勇',mobile:'13588881234'}, {id:4,name:'钱行',mobile:'13598092735'} ]; }]); </script> </body> </html>
相关文章推荐
- angularJs自定义过滤器实现手机号信息隐藏
- angularJs自定义过滤器实现手机号信息隐藏的方法
- AngularJs Filter详解2--自定义过滤器
- AngularJS 自定义过滤器
- angularJS自定义过滤器使用
- Angularjs自定义过滤器
- AngularJS 自定义过滤器
- AngularJs学习笔记__6、自定义过滤器,阿拉伯数字金额转汉字金额
- 《AngularJs》$filter 自定义过滤器
- AngularJs自定义过滤器
- AngularJS的组件化、过滤器、自定义过滤器之旅
- Angularjs 依赖压缩及自定义过滤器写法
- angularjs-过滤器中,使用自定义服务
- angularJS 自定义过滤器
- AngularJs中组件、过滤器、自定义过滤器的使用
- angularJS自定义过滤器、服务和指令
- AngularJS中过滤器的使用与自定义实例代码
- (9)AngularJS 1.X 之自定义过滤器
- AngularJs自定义过滤器
- Angularjs学习笔记——AngularJS中$filter过滤器使用(自定义过滤器)