title: Angularjs $http deleting data from server
body: <p>i need to delete a received data from "play" server by using angularjs.</p>
  
  <p>I'm using a "play" server and eclipse to save the data on server.</p>
  
  <p>script.js (adding item)</p>
  
  <pre><code>    app.controller('myCtrl', function($scope, $http) {
  //---Add car---//
      $scope.addCar = function() {
          $http({
              method : "GET",
              url : "http://localhost:9000/addCar",
              params : {
                  manufacture : $scope.manufacturer.name,
                  year : $scope.year.name,
                  number : $scope.number,
                  model : $scope.model,
                  price : $scope.price,
                  color : $scope.myColor.name,
                  engine : $scope.engine.name
              }
          });
          alert("Car Successfuly added!");
      };
  </code></pre>
  
  <p>Application.java (adding function to arrayList)</p>
  
  <pre><code>public static Result addCar(String manufacture, String year, String number, String model, String price, String color, String engine)
      {
          response().setHeader("Access-Control-Allow-Origin", "*");
          Car c = new Car(manufacture, year, number, model, price, color, engine);
          cars.add(c);
          return ok(Json.toJson(cars));
      }
  </code></pre>
  
  <p>script.js (Getting data from server) here i can use <code>&lt;tr ng-repeat="car in cars"&gt;</code> and print all cars in page</p>
  
  <pre><code>    //---Get car---//
          $http({
              method : "GET",
              url : "http://localhost:9000/getCars"
          }).success(function(data) {
              $scope.cars = data;
   });
  </code></pre>
  
  <p>Application.java (getting json)</p>
  
  <pre><code>public static Result getCars()
      {
          response().setHeader("Access-Control-Allow-Origin", "*");
          return ok(Json.toJson(cars));
      }
  </code></pre>
  
  <p>After this i can put my data on html page</p>
  
  <pre><code>&lt;h1&gt;Car list&lt;/h1&gt;
  &lt;div ng:controller="myCtrl"&gt;
      &lt;table class="table"&gt;
          &lt;tr ng-repeat="car in cars"&gt;
              &lt;td&gt;{{car.manufacture}}&lt;/td&gt;
              &lt;td&gt;{{car.year}}&lt;/td&gt;
              &lt;td&gt;{{car.number}}&lt;/td&gt;
              &lt;td&gt;{{car.model}}&lt;/td&gt;
              &lt;td&gt;{{car.price}}&lt;/td&gt;
              &lt;td&gt;{{car.color}}&lt;/td&gt;
              &lt;td&gt;{{car.engine}}&lt;/td&gt;
              &lt;td&gt;[&lt;a href ng:click="removeItem($index)"&gt;X&lt;/a&gt;]
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>How i can delete item (car) from data(cars) like here:</p>
  
  <pre><code>$scope.removeItem = function(index) {
          //This code deleting data from page, not from server
          $scope.cars.splice(index, 1);
      };
  });
  </code></pre>
  
  <p>{edit}</p>
  
  <p>im trying to do something like this:</p>
  
  <p>in script.js</p>
  
  <pre><code>$scope.removeItem = function() {
          $http({
              method : "GET",
              url : "http://localhost:9000/removeCar",
              params : {
                  manufacture : $scope.manufacturer.name,
                  year : $scope.year.name,
                  number : $scope.number,
                  model : $scope.model,
                  price : $scope.price,
                  color : $scope.myColor.name,
                  engine : $scope.engine.name
              }
          });
          alert("Car Successfuly deleted!");
      };
  </code></pre>
  
  <p>in Application.java</p>
  
  <pre><code>public static Result removeCar(String manufacture, String year, String number, String model, String price, String color, String engine)
      {
          response().setHeader("Access-Control-Allow-Origin", "*");
          Car c = new Car(manufacture, year, number, model, price, color, engine);
  
          for(int i=0; i&lt;cars.size();i++)
              if(cars.get(i).equals(c)){
                  cars.remove(i);
              }
          return ok(Json.toJson(cars));
      }
  </code></pre>
  
  <p>but its not working</p>