title: TypeError: push is not a function
body: <p>Here is my code for factories.html</p>
  
  <pre><code>    af.factory("PurchaseFactory",function(){
  
      var productlist={products:[]};
  
      return{
          getpurchaseCart:function(){
              return productlist;
          },
          addPurchaseCart:function(products){
          productlist.products.push(products);
  
      }
  
      }
  })  
  </code></pre>
  
  <p>For Services.html</p>
  
  <pre><code> as.service("PurchaseService",function(PurchaseFactory){
  
      this.getAllPurchase=function(){
          return PurchaseFactory.getpurchaseCart();
      }
      this.addPurchase=function(products)
      {
          PurchaseFactory.addPurchaseCart(products);
      }
  }) 
  </code></pre>
  
  <p>For Controller.html</p>
  
  <pre><code>  ac.controller("PurchaseController",function($scope,PurchaseService){  
       $scope.savepurchase=function(products){
               if($scope.products._id==undefined){            
              $scope.products=angular.extend($scope.products,$scope.sizes)
               PurchaseService.addPurchase($scope.products);
                 }       
      }
      }
  </code></pre>
  
  <p>Here i have an another function in the same controller, as </p>
  
  <pre><code>$scope.saveorder=function(cartorder){       
      $scope.Mainpurchaselist=angular.extend($scope.cartorder,$scope.getpurchaseList)
           CartService.addPurchaseCart($scope.Mainpurchaselist);
          $scope.getpurchaseList.products={}
           $scope.cartorder={}                                         
           $scope.products={}                                         
        $rootScope.isLogin=false;
       CartService.deletecartyPurchase(idx);
      Notification.success({message: 'your Cart Saving Successfully', delay: 1000});
      } 
  </code></pre>
  
  <p>In my HTML file, i have a button with function as savepurchase(products).
  For first time its saving data but from second time its showing me error as TypeError:productlist.products.push is not a function. If I refresh the page its again saving the data, but continuously its not working.Let me know where the code goes wrong.
  Here $scope.getpurchaselist.products={} is used to make a data null for every new purchase. If I remove the $scope.getpurchaselist.products={}, its working fine with no error but the problem is that the list is not getting null.
  SO finally i have two ways 
  1. either to make it null by writing $scope.getpurchaselist.products={} but error as productlist.products.push is not a function let me know to overcome that error
  2. Or to remove that line and let me know, how to make it null</p>