zoukankan      html  css  js  c++  java
  • angular-filter中join/unique属性运用

    join属性:
    例如: 数组name=['John', 'Sebastian', 'Will', 'James']; 若是想把数组中的对象全部筛选并显示出来,可以直接在HTML里面运用angular-filter中的join属性; 用法<p>{{ names | join:', ' }}</p> name为数组名称,join:','显示数组的连接符

     

    unique属性:
    unique属性为筛选出数组中唯一的对象
    
    var name = $filter('unique')(筛选的数组,'筛选条件');
    
    例如:
    $scope.orders = [
        { id:1, customer: { name: 'John', id: 10 } },
        { id:2, customer: { name: 'William', id: 20 } },
        { id:3, customer: { name: 'John', id: 10 } },
        { id:4, customer: { name: 'William', id: 20 } },
        { id:5, customer: { name: 'Clive', id: 30 } }
      ];
    
    var name = $filter('unique')(orders , 'name');
    
    筛选结果为:
    $scope.name =[
        { id:1, customer: { name: 'John', id: 10 } },
        { id:2, customer: { name: 'William', id: 20 } },
        { id:5, customer: { name: 'Clive', id: 30 } }
    ]
    
    筛选出orders数组中name唯一的对象;
    

      

  • 相关阅读:
    Educational Codeforces Round 81 (Rated for Div. 2) A-E
    SEERC 2018 I
    manjaro linux java环境配置
    Pangu and Stones HihoCoder
    Linux下 vim 的配置
    C++内存管理技术
    Interview_C++_day27
    Interview_C++_day26
    Interview_C++_day25
    Interview_数据库_day24
  • 原文地址:https://www.cnblogs.com/ncloud/p/7746013.html
Copyright © 2011-2022 走看看