javascript - ngRepeat 按深度属性过滤

如果我有一个以对象作为属性值的复杂对象,如何按其中一个嵌套属性进行过滤?

这可以通过 OOB ng-repeat 过滤器完成吗?

数据

{
  Name: 'John Smith',
  Manager: {
     id: 123,
     Name: 'Bill Lumburg'
  }
}

ngRepeat

<li ng-repeat="e in emps | filter:Manager.Name">{{ e.Name }}</li>

最佳答案

你需要传入参数来过滤:

<input ng-model="filter.key">
<ul>
  <li ng-repeat="e in list | filter: {Manager: {Name: filter.key}}">
    {{e.Name}}  (Manager: {{e.Manager.Name}})
  </li>
</ul>

Example on Plunker

https://stackoverflow.com/questions/27606595/

相关文章:

javascript - JSON.stringify 深层对象

sql - 如何查询空对象的 json 列?

java - 在不知道 JSON 格式的情况下用 Java 解析 JSON

c# - 为什么 DateTime.MinValue 不能在 UTC 之前的时区中序列化?

c# - asp.net asmx Web 服务返回 xml 而不是 json

json - 在 shell 脚本中读取 JSON 数据

python - 无返回时处理 JSON 解码错误

json - 将逻辑表示为 JSON 中的数据

c# - 复杂类型在 ApiController 参数中为空

java - JSON - 遍历 JSONArray