zoukankan      html  css  js  c++  java
  • angular第五天

    1、$filter

    2、自定义过滤器

    <!-- index.html -->
    <!DOCTYPE html>
    <html ng-app="myApp">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script src="angular.js"></script>
    </head>
    <body>
        <div ng-controller="firstController">
            <p>{{ name }}</p>
            <p>{{ num }}</p>
        </div>
    </body>
    <script type="text/javascript">
        var app = angular.module("myApp", []);
        app.controller('firstController', ['$scope','$filter', function($scope, $filter){
       
            $scope.num = 344342342357.32342565;
            $scope.name = $filter("firstUpper")("hello");
        }]);
    
        //自定义过滤器的写法是返回一个函数
        app.filter("firstUpper",function(){
            //这里的参数就是使用过滤器的时候传入的参数
            return function(str,num,nu2){
                // console.log(str);
                // console.log(num);
                // console.log(nu2);
                return str.charAt(0).toUpperCase()+str.substring(1);
            }
        })
    </script>
    </html>
  • 相关阅读:
    【PAT】1001 害死人不偿命的(3n+1)猜想(动态更新)
    文件指令集
    近距离接触电脑
    文件管理
    文件写作方法
    文件读取方法
    打开文件的逻辑
    话术库
    max的逻辑
    抽象化指令
  • 原文地址:https://www.cnblogs.com/gao-xiong/p/5963038.html
Copyright © 2011-2022 走看看