AngularJS filter

作者: 还是老徐ooo | 来源:发表于2018-04-13 15:07 被阅读19次

     $filter 

    1、 currency格式化数字为货币格式。

    var orderBy  = $filter('orderBy');

    $scope.list =orderBy(list,'age',true);

    var price ="11.11";

    var currency  = $filter('currency');

    console.log(currency);

    $scope.price =currency(price,'$');

    2、lowercase格式化字符串为小写。

    3、uppercase格式化字符串为大写。

    var  hello ='Hello World!!!!!';

    var uppercase  = $filter('uppercase');

    $scope.hello =uppercase(hello);

    var lowercase  = $filter('lowercase');

    $scope.low =lowercase(hello);

    4、orderBy根据某个表达式排列数组 

    var list = [

    {name:'css',age:6},

    {name:'jss',age:26},

    {name:'html',age:16},

    {name:'json',age:166},

    ];

    5、number   angularjs过滤器number,用来精确浮点数

    var number = $filter('number');

    var count =number(123.456789,2);//123.46

    var count =number(123.12345,10);//123.1234500000

    6、limitTo  (限制数组长度或字符串长度)

    var limitTo = $filter('limitTo');

    console.log(limitTo('123456789',1));   //1

    console.log(limitTo('123456789',2));   //12

    console.log(limitTo('123456789',1,3));  //4

    4、filter从数组项中选择一个子集 还没学习,暂时用不着

    相关文章

      网友评论

        本文标题:AngularJS filter

        本文链接:https://www.haomeiwen.com/subject/btpckftx.html