zoukankan      html  css  js  c++  java
  • 【Angular】过滤器

    AngularJS学习笔记

    {{ name | uppercase}}
    {{ 123.456789 | number:2 }}
    
    app.controller('DemoController', ['$scope', '$filter', function($scope, $filter) {
        $scope.name = $filter('lowercase')('Ari')
    }])

    过滤器也可以带参数,多个参数之间使用:分割

    <!DOCTYPE html>
    <html ng-app="Demo">
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
       <script src="jquery-1.8.3.min.js"></script>
       <script src="angular.min.js"></script>
       <div ng-controller="TestCtrl">
           <p>示例数据: {{ a|map:map_value:'&gt;&gt;':'(no)' }}</p>
           <p>示例数据: {{ b|map:map_value:'&gt;&gt;':'(no)' }}</p>
       </div>
       <script>
            var app = angular.module('Demo', [], angular.noop)
            app.controller('TestCtrl', function($scope) {
                $scope.map_value = {
                    a: '',
                    b: '',
                    c: ''
                }
                $scope.a = 'a'
            })
    
            app.filter('map', function() {
                var filter = function(input, map_value, append, default_value) {
                    console.log(input, map_value, append, default_value)
                    var r = map_value[input]
                    if (r === undefined) {
                        return default_value + append
                    } else {
                        return r + append
                    }
                }
                return filter
            })
       </script>
    </body>
    </html>
  • 相关阅读:
    Nim or not Nim? hdu3032 SG值打表找规律
    Maximum 贪心
    The Super Powers
    LCM Cardinality 暴力
    Longge's problem poj2480 欧拉函数,gcd
    GCD hdu2588
    Perfect Pth Powers poj1730
    6656 Watching the Kangaroo
    yield 小用
    wpf DropDownButton 源码
  • 原文地址:https://www.cnblogs.com/jzm17173/p/4217831.html
Copyright © 2011-2022 走看看