首页 > Web开发 > 详细

angularjs自定义filter

时间:2018-06-25 21:22:40      阅读:174      评论:0      收藏:0      [点我收藏+]

angular.Module API

Overview
Methods
info([info]);
provider(name, providerType);
factory(name, providerFunction);
service(name, constructor);
value(name, object);
constant(name, object);
decorator(name, decorFn);
animation(name, animationFactory);
filter(name, filterFactory);
controller(name, constructor);
directive(name, directiveFactory);
component(name, options);
config(configFn);
run(initializationFn);
Properties
requires
name

filter(name, filterFactory);

See $filterProvider.register().

Note: Filter names must be valid AngularJS Expressions identifiers, such as uppercase or orderBy. Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace your filters, then you can use capitalization (myappSubsectionFilterx) or underscores (myapp_subsection_filterx).
--Parameters--
Param Type Details
name string
Filter name - this must be a valid AngularJS expression identifier

filterFactory Function
Factory function for creating new instance of filter.

Demo

    angular.module(‘mobile‘)
        .filter(‘mobileMask‘, function() {
            return function(input) {
                var mobile = input || ‘‘;
                var reg = /\d{11}/;
                if (reg.test(mobile)) {
                    return mobile.replace(/(\d{3})(\d{4})(\d{4})/, ‘$1****$3‘);
                }
                return input;
            }
        });

angularjs自定义filter

原文:https://www.cnblogs.com/wancy86/p/9226222.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!