title: How to filter JSON object array across nested array with in it
body: <p>I have an object array and i am filtering it against property name "username" like this.</p>
  
  <pre><code>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"
          }
        ]
      }
    ]
  </code></pre>
  
  <p>and the filter function is like this</p>
  
  <pre><code>  transform(array: any, valueToSearch: string): any[] {
  
        return array.filter(e =&gt; 
         e.username.toLowerCase().indexOf(valueToSearch.toLowerCase()) 
         !== -1);
  
       }
  </code></pre>
  
  <p>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</p>
  
  <pre><code>return agents.filter(e =&gt; e.roles.filter(ee =&gt; 
         ee.valueToSearch.toLowerCase()) !== -1));
  </code></pre>
  
  <p>but it didn't work.</p>
  
  <p>this is dmeo 
  <a href="https://stackblitz.com/edit/angular-txchxs?embed=1&amp;file=src/app/agentFilter.pipe.ts" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-txchxs?embed=1&amp;file=src/app/agentFilter.pipe.ts</a></p>