title: delete row(s) from ng-grid table from button
body: <p>I have a table with ng-grid, and the problem is that i'm not sure how to collect the selected row(s) id or variable to pass into my delete function.</p>
  
  <p>here is a quick mockup of what i'm trying to do</p>
  
  <p><a href="http://plnkr.co/edit/zy653RrqHmBiRJ7xDHlV?p=preview" rel="nofollow">http://plnkr.co/edit/zy653RrqHmBiRJ7xDHlV?p=preview</a></p>
  
  <p>the following code is from my html, a clickable delete button that takes in 2 parameters, the array of checkbox ids and the index at the corresponding table. This delete method was obtained from this tutorial : <a href="http://alexpotrykus.com/blog/2013/12/07/angularjs-with-rails-4-part-1/" rel="nofollow">http://alexpotrykus.com/blog/2013/12/07/angularjs-with-rails-4-part-1/</a>    </p>
  
  <pre><code> &lt;div class="btn-group"&gt;
    &lt;button class="my-btn btn-default button-row-provider-medical-services" ng-click="deleteProviderMedicalService([], $index)"&gt;Delete&lt;/button&gt;
    &lt;/button&gt;
  &lt;/div&gt;
   &lt;div class="gridStyle ngGridTable" ng-grid="gridOptions"&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>The following code  grabs the json data from a url, queries it and returns it. It also contains the delete function that gets called from the controller in the html page.</p>
  
  <pre><code>app.factory('ProviderMedicalService', ['$resource', function($resource) {
  function ProviderMedicalService() {
  this.service = $resource('/api/provider_medical_services/:providerMedicalServiceId', {providerMedicalServiceId: '@id'});
  };
  
  ProviderMedicalService.prototype.all = function() {
  return this.service.query();
  };
  
  
  ProviderMedicalService.prototype.delete = function(providerId) {
  this.service.remove({providerMedicalServiceId: providerId});
  };
  
  return new ProviderMedicalService;
  }]);
  </code></pre>
  
  <p>The following is my controller(not everything, just the most important bits). $scope.provider_medical_services gets the json data and puts it into the ng-grid gridOptions.
  After reading the ng-grid docs, i must somehow pass the checkbox ids from the selectedItems array and pass it into html doc to the delete function. Or, i'm just doing this completely wrong, as i hacked this together. Solutions and suggestions are greatly appreciated</p>
  
  <pre><code>  (function() {
    app.controller('ModalDemoCtrl', ['$scope', 'ProviderMedicalService', '$resource', '$modal', function($scope, ProviderMedicalService, $resource, $modal) {
  
  
   var checkBoxCellTemplate = '&lt;div class="ngSelectionCell"&gt;&lt;input tabindex="-1" class="ngSelectionCheckbox" type="checkbox" ng-checked="row.selected" /&gt;&lt;/div&gt;';
  
   $scope.provider_medical_services = ProviderMedicalService.all();
  
   $scope.deleteProviderMedicalService = function(ids,idx) {
    $scope.provider_medical_services.splice(idx, 1);
    return ProviderMedicalService.delete(ids);
   };
  
   $scope.gridOptions = {
      columnDefs: [
       {
          cellTemplate: checkBoxCellTemplate,
          showSelectionCheckbox: true
        },{
          field: 'name',
          displayName: 'CPT Code/Description'
        },{
          field: 'cash_price',
        displayName: 'Cash Price'
        },{
          field: 'average_price',
          displayName: 'Average Price'
        },
  
       ],
       data: 'provider_medical_services',
       selectedItems: []
  
     };
  </code></pre>