1.  filter可以接收参数,参数用 : 进行分割,如下:

{{ expression | filter:argument1:argument2:... }}

2.   filter参数是 对象 ,匹配属性中含有value的

$scope.childrenArray = [
{name:'kimi',age:3},
{name:'cindy',age:4},
{name:'anglar',age:4},
{name:'shitou',age:6},
{name:'tiantian',age:5}
]; {{ childrenArray | filter : {name : 'i'} }} //参数是对象,匹配name属性中含有i的

示例:angular filter多个字段搜索

<input type="text" ng-model="search ">

<!--<li ng-repeat="user in data.users | filter:{name:search}>  -->
<!--此时只搜索了name字段--> <!--搜索name字段、account字段-->
<li ng-repeat="user in data.users | filter:{name:search}:{account:search}>
<span ng-bind="user.name"></span>
<span ng-bind="user.account"></span>
</li>

3.  没有指定过滤哪个字段的情况下,默认filter会匹配所有字段(name、account)的值,类似 多个字段搜索

ng-repeat="user in data.users | filter:search

4. $ 匹配 对象 所有属性 和  嵌套对象属性

<li ng-repeat="user in data.users | filter:{$:search}> 

5.  bind ng-model to the “value” of selected item  instead of item for ui-select

  <ui-select ng-model="fm.countryCode" id="countryCode">
<ui-select-match placeholder="Select a country...">{{$select.selected.label}}</ui-select-match>
<ui-select-choices repeat="item in countries | filter: $select.search" value="{{$select.selected.value}}">
<div ng-bind-html="item.label | highlight: $select.search"></div>
<small ng-bind-html="item.value | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>

Currently it's just setting fm.countryCode to the whole country item.

For example if I select Afghanistan, fm.countryCode will be set to {"value":"AF","label":"Afghanistan"}.

What I want is "AF".

so change  the repeat part

<ui-select-choices repeat="item in countries | filter: $select.search" value="{{$select.selected.value}}">

to

<ui-select-choices repeat="item.value as item in countries | filter: $select.search" value="{{$select.selected.value}}">

 示例:

                                            <ui-select ng-model="networkDefaultValue.resourceId" name="networkname" theme="bootstrap" ng-change="setInputDefaultValue(['resource_id'],networkDefaultValue.resourceId,networkDefaultValue.isResourceIdInput)">
<ui-select-match allow-clear="true" placeholder="{{'Select an option'|translate}}">{{$select.selected.name + ' - ' + $select.selected.properties.datacentername}}</ui-select-match>
<ui-select-choices repeat="resource.id as resource in totalNetworks | filter: { $ : $select.search}">
<div ng-bind-html="resource.name + ' - ' + resource.properties.datacentername | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>

参考网址:

走进AngularJs(七) 过滤器(filter)

AngularJS filter:search 是如何匹配的 ng-repeat filter:search

AngularJS filter:search 是如何匹配的 ng-repeat filter:search ,filter:{$:search},只取repeat的item的value 不含label的更多相关文章

  1. Python: re.compile最短匹配模式,只取双引号内的值\“

    用正则表达式匹配某个文本模式 1.只取双引号内的值 2.长短匹配模式对比 贪婪模式:     模式r'\"(.*)\" '的意图是匹配被双引号包含的文本,但是这个表达式中*是贪婪的 ...

  2. Web.xml中设置Servlet和Filter时的url-pattern匹配规则

    一.servlet容器对url的匹配过程: 当一个请求发送到servlet容器的时候,容器先会将请求的url减去当前应用上下文的路径作为servlet的映射url,比如我访问的是http://loca ...

  3. 四十七.iptables防火墙 filter表控制 扩展匹配 nat表典型应用

    1.iptables基本管理 关闭firewalld,开启iptables服务 查看防火墙规则 追加.插入防火墙规则 删除.清空防火墙规则   1.1 关闭firewalld,启动iptables服务 ...

  4. Python:正则表达式(二):如何使用re.search()返回的匹配对象中的具体内容呢??

    在上一篇中讲述了re.seach()会返回一个对象格式的数据,如下:<_sre.SRE_Match object; span=(16, 24), match='${phone}'> 那么问 ...

  5. AngularJS中angular.min.js:80 Error: [ng:areq] http://errors.angularjs.org/1.2.9/ng/areq

    报出来的时候,出现这种错误,是因为在引入控制器的时候没有引入成功,我遇到这个错误是在因为没有将父控制器引入到子控制器中.

  6. C#中正则表达式只取前N个匹配结果

    用Regex.Matches方法可以得到同指定正则表达式对应的所有匹配结果.有时,所有匹配结果可能有成千上万个,考虑到性能效率的因素,只需要取出前N个匹配结果.下面的代码演示了做法: 需求:取字符串中 ...

  7. filter 死循环(tomcat 启动完成 ,自动执行filter.dofilter,导致tomcat 启动超时) , tomcat 启动和 servers 启动 不同

    package com.diancai.interceptor; import java.io.IOException; import javax.servlet.Filter; import jav ...

  8. dubbo白名单通过filter,spring web通过拦截器或者filter即可

    在开发中,有时候需要限制访问的权限,白名单就是一种方法.对于Java Web应用,Spring的拦截器可以拦截Web接口的调用:而对于dubbo接口,Spring的拦截器就不管用了. dubbo提供了 ...

  9. 'org.springframework.web.filter.CharacterEncodingFilter' is not assignable to 'javax.servlet.Filter,This inspection lets you spot the following problems that might occur in descriptors that are used t

    1.jar包导入错误,因为maven下载的原因: 删除这样的包,然后让maven重新下载,问题就会解决

随机推荐

  1. repcached与mysql缓存測试

    使用gem安装mysql引擎 gem install mysql(假设安装失败.请查找一些依赖组建是否安装,比如mysql-devel) 编写ruby脚本,先获取mysql数据,之后从memcache ...

  2. 07 Test结构

    Test 有多种实现方式, [ 等价于 test, 并且 [ 是一个内建命令, 效率很高 另外, [[]] 也是测试, [[]]结构比bash[]更灵活, 这是一个扩展test命令, 从ksh88继承 ...

  3. SQL on Hadoop 的真相(1)

    转自:http://blog.jobbole.com/86710/ 这是一组系列博文,目的是详尽介绍 SQL-on-Hadoop .本系列的第一篇会介绍 Hadoop 系统的存储引擎和在线事务处理(简 ...

  4. ytu 1052: 写一函数,将两个字符串连接(水题,指针练习)

    1052: 写一函数,将两个字符串连接 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 343  Solved: 210[Submit][Status][ ...

  5. hdu 4708(暴力+找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4708 思路:由于N不大,并且我们可以发现通过旋转得到的4个对角线的点的位置关系,以及所要旋转的最小步数 ...

  6. 系统管理模块_岗位管理_实现CRUD功能的具体步骤并设计Role实体

    系统管理模块_岗位管理_实现CRUD功能的具体步骤并设计Role实体 1,设计实体/表 设计实体 --> JavaBean --> hbm.xml --> 建表 设计Role实体 p ...

  7. std::condition_variable

    /* std::condition_variable 提供了两种 wait() 函数.当前线程调用 wait() 后将被阻塞(此时当前线程应该获得了锁(mutex),不妨设获得锁 lck),直到另外某 ...

  8. HYSBZ 1036(树的统计Count)

    题目链接:传送门 题目大意:中文题,略 题目思路:树链剖分裸题. 闲谈:树链越练越熟练了 #include <iostream> #include <cstdio> #incl ...

  9. vue通信

    组件实例的作用域是孤立的. 一.父子通信 父组件通过props向下传递数据给子组件,子组件通过events给父组件发送消息. 要让子组件使用父组件的数据,我们需要通过子组件的props选项.prop是 ...

  10. node npm

    node.js -npm 查看npm版本号$ npm -v 全局安装npm$ npm install npm -g 安装模块$ npm install <module name> --本地 ...