Issues with datatables in angular js

364 views
Skip to first unread message

sravya srungarapu

unread,
Jun 27, 2014, 2:43:11 PM6/27/14
to ang...@googlegroups.com
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

Tandon, Rishi

unread,
Jun 27, 2014, 3:40:36 PM6/27/14
to ang...@googlegroups.com
You might want to use $apply method 
--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.


--
Rishi Tandon
Pearson Learning Technology Group

Mobile: (310) 926-9032

Pearson
Always Learning
Learn more at www.pearson.com

sravya srungarapu

unread,
Jun 28, 2014, 1:29:22 PM6/28/14
to ang...@googlegroups.com
Hi thank you for the response. i have already tried that..but it did not work.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Alejandro Paciotti

unread,
Jun 28, 2014, 6:48:00 PM6/28/14
to ang...@googlegroups.com
I can't see the attachment.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages