zoukankan      html  css  js  c++  java
  • [angularjs] angularjs系列笔记(四)过滤器

    过滤器可以使用一个管道字符(|)添加到表达式和指令中,这不就是模板函数吗

      <body>
        <div ng-app="Home">
          <div ng-controller="Index">
            格式化字符串为小写
            {{myName()|lowercase}}。
            格式化字符串为大写
            {{myName()|uppercase}}。
            格式化数字为货币格式
            {{price|currency}}。
            根据某个表达式排列数组
            <p ng-repeat="x in prices | orderBy:'price'">{{x.price}}</p>
            。
            取出数组中的子元素
            <input type="text" ng-model="test">
             <p ng-repeat="x in prices |filter:test | orderBy:'price'">{{x.price}}</p></div>
        </div>
    
      </body>
    
      <script type="text/javascript">
      //实例化应用对象,参数:模块名,空数组
      var app=angular.module("Home",[]);
      //调用Application对象的controller()方法
      app.controller("Index",function($scope){
        $scope.myName=function(){
          return "Tao"+"ShiHan";
        }
        $scope.price=5;
        $scope.prices=[{price:1},{price:5},{price:3}];
      });
      </script>
  • 相关阅读:
    前后端微服务联调
    Rancher搭建ES容器集群
    Rancher解决磁盘占满异常
    Rancher搭建Redis主从集群
    Rancher搭建NFS持久存储
    Linux普通用户管理
    Rancher部署mysql8
    Delegate背后的秘密
    Java——反射
    redis 操作命令
  • 原文地址:https://www.cnblogs.com/taoshihan/p/5309176.html
Copyright © 2011-2022 走看看