Hi,

I created a simple datatable using angular js. When I run this code, the 
datatable shows up properly. I wrote ng-click to delete the particular row 
from datatable. When i test the code below and click on any of the 
lastnames the element is getting removed from array persons but not from 
datatable. Am I doing anything wrong here? Please help. I have attached 
complete code(example.html).

*My HMTL Code*:
<div ng-controller="simpleCtrl">
<table datatable="ng">
      <thead>
        <tr>
          <th>ID</th>
          <th>FirstName</th>
          <th>LastName</th>
        </tr>
      </thead>
      <tbody>
        <tr dt-rows ng-repeat="person in persons">
          <td>{{ person.id }}</td>
          <td>{{ person.firstName }}</td>
          <td><a ng-click='remove(person)'>{{ person.lastName }}</a></td>
        </tr>
      </tbody>
    </table>
</div>

*Controller code:*
 controller('simpleCtrl', function($scope, $http) {
        $scope.persons = [];
        $http.get('data.json').success(function(persons) {
          $scope.persons = persons;
        });

        $scope.remove = function(item){
          var index = $scope.persons.indexOf(item);  
console.log(index);
$scope.persons.splice(index,1);
console.log($scope.persons);
}
    });

Thanks,
Sravya

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to