I have an object array and i am filtering it against property name "username" like this.

```
array =   [{
    "id": 1,
    "username": "admin",
    "roles": [{
            "name": "Administrator"
        },
        {
            "name": "agent"
        }
    ]
},
{
    "id": 2,
    "username": "admin2",
    "roles": [{
            "name": "Administrator2"
        },
        {
            "name": "agent2"
        }
    ]
},
{
    "id": 3,
    "username": "admin3",
    "roles": [{
            "name": "Administrator3"
        },
        {
            "name": "agent3"
        }
      ]
    }
  ]

```

and the filter function is like this

```
  transform(array: any, valueToSearch: string): any[] {

      return array.filter(e => 
       e.username.toLowerCase().indexOf(valueToSearch.toLowerCase()) 
       !== -1);

     }

```

everything works fine, but now i want to filter against the property name "name" in "roles" array in the object. for example i would like to return an object whose "roles" array contains "name" = agent3 , so it should return the whole object which is located at the last in my example. i tried like

```
return agents.filter(e => e.roles.filter(ee => 
       ee.valueToSearch.toLowerCase()) !== -1));

```

but it didn't work.

this is dmeo 
<https://stackblitz.com/edit/angular-txchxs?embed=1&file=src/app/agentFilter.pipe.ts>