title: Copying specific objects(according to given condition) from array of objects into an another array in angularJS
body: <p>I want to create a new array of objects from an existing array of objects , such that new array will have only have those objects which matches the condition defined in if statement. Below is the code snippet which i am attempting</p>
  
  <p>Requirement is that when key.status=='completed' condition gets hit ,only those object which have status : 'completed' in orders array will get copied to temp array .But because of using angular.copy whole copy of objects is getting copied in temp array .
   .</p>
  
  <p>--------html-----</p>
  
  <pre><code>&lt;body ng-app ="myModule"&gt;
      &lt;div ng-controller="myController"&gt;    
      &lt;div ng-repeat="order in temp"&gt;
  
      {{order.id}} -- {{order.status}} -- {{order.name}}
  
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>-------xxxx------</p>
  
  <p>-------JS----------</p>
  
  <pre><code>&lt;script&gt;
  
  
    var myModule = angular.module('myModule', []);
  
    myModule.controller('myController',  function($scope) {
  
      $scope.orders = [ 
        {id: '101' , status : 'completed' , name: 'Jacopo' } ,
        {id: '102' , status : 'Rejected' , name: 'Dan' } ,
        {id: '103' , status : 'created' , name: 'Erick' } 
      ] ;
  
      $scope.temp = [ ] ;
  
      angular.forEach($scope.orders , function(key,value){ 
        if(key.status == 'completed') {
        angular.copy($scope.orders,$scope.temp)
        }
  
      } );
  
    } ) ;
  
  &lt;/script&gt;
  </code></pre>
  
  <p>------xxx--------</p>