Filter在Angularjs对象中有数组

时间:2017-05-30 07:29:06

标签: angularjs

我想在对象数组中过滤我的结果是代理数组

[
{
 "id": 1,
"queue_id": 15,
"agent_id": 3,
"level": 0,
"position": 0,
"created_at": "2017-05-29T17:45:08.000Z",
"updated_at": "2017-05-29T17:45:08.000Z",
"callcenter_agent": {
  "id": 3,
  "name": "1254",
  "type": "1",
  "status": null,
  "max_no_answer": 0,
  "wrap_up_time": 5,
  "reject_delay_time": 5,
  "busy_delay_time": 5,
  "no_answer_delay_time": 5,
  "user_number_id": 35,
  "created_at": "2017-05-29T17:30:14.000Z",
  "updated_at": "2017-05-29T17:30:14.000Z"
 }
},
{
  "id": 2,
  "queue_id": 15,
  "agent_id": 4,
  "level": 0,
  "position": 0,
  "created_at": "2017-05-29T17:45:24.000Z",
  "updated_at": "2017-05-29T17:45:24.000Z",
  "callcenter_agent": {
  "id": 4,
  "name": "3658",
  "type": "1",
  "status": null,
  "max_no_answer": 0,
  "wrap_up_time": 5,
  "reject_delay_time": 5,
  "busy_delay_time": 5,
  "no_answer_delay_time": 5,
  "user_number_id": 36,
  "created_at": "2017-05-29T17:30:27.000Z",
  "updated_at": "2017-05-29T17:30:27.000Z"
}
}
];

我想要使用角度过滤器过滤callcenter_agent.name  我在html中的代码是

 <li ng-click="selectagents(x)" ng-repeat="x in agents | filter:
    {callcenter_agent.name : checkagents } ">
   <a ng-bind="x.callcenter_agent.name"> </a>
 </li>

但是如何在callcenter_agents中过滤名称是错误的?
我想为voip写一个callcenter manager

1 个答案:

答案 0 :(得分:1)

像这样修改过滤器

<li ng-click="selectagents(x)" ng-repeat="x in agents | filter:{callcenter_agent: {name: checkagents}}"">
   <a ng-bind="x.callcenter_agent.name"> </a>
 </li>