title: Remove duplicate values from json array using angular js
body: <p>I want to remove duplicates from the following json array</p>
  
  <pre><code>$scope.array = [
      {"name":"aaa","key":"1"},
      {"name":"bbb","key":"2"},
      {"name":"aaa","key":"1"},
      {"name":"ccc","key":"3"},
      {"name":"bbb","key":"2"}
  ];
  </code></pre>
  
  <p>I tried following code but its not working</p>
  
  <pre><code>var ids = {};
  
  $scope.array.forEach(function (list) {
      ids[list.name] = (ids[list.name] || 0) + 1;
  });
  
  var finalResult = [];
  $scope.array.forEach(function (list) {
      if (ids[list.name] === 1) finalResult.push(student);
  });
  
  console.log(finalResult);
  </code></pre>
  
  <p>This is the expected result.</p>
  
  <pre><code>$scope.array = [
      {"name":"aaa","key":"1"},
      {"name":"bbb","key":"2"} ,
      {"name":"ccc","key":"3"} 
  ];
  </code></pre>