-1

I am really new to the world of angularjs and I am working on angular 1.5

What I am trying to do is remove the duplicate records from the response before assigning it to the $scope

The results that i get looks like as following

[
{
    "phoneNumbers": [
      {
        "value": "00 1 111-222-333",
        "pref": false,
        "id": 0,
        "type": null
      },
      {
        "value": "00 1 222-222-333",
        "pref": false,
        "id": 1,
        "type": null
      },
      {
        "value": "00 1 333-222-333",
        "pref": false,
        "id": 2,
        "type": null
      }
    ]
  },{
    "phoneNumbers": [
      {
        "value": "00 1 111-222-333",
        "pref": false,
        "id": 0,
        "type": null
      },
      {
        "value": "00 1 222-222-333",
        "pref": false,
        "id": 1,
        "type": null
      },
      {
        "value": "00 1 333-222-333",
        "pref": false,
        "id": 2,
        "type": null
      }
    ]
  }]

You will notice that there are 2 arrays and both have sub array called phoneNumbers and they have the exact same value.

What I need is if phoneNumbers of any array matches the phoneNumbers of another array then remove that array all together from the response.

I will really appreciate any help on this.

enter image description here

Saadia
  • 856
  • 1
  • 12
  • 32

1 Answers1

0

This is not angularjs question, but rather general question of comparing objects and arrays. You can find good example in the answer to this question https://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript

Community
  • 1
  • 1
Bojana Šekeljić
  • 1,056
  • 1
  • 12
  • 30