How to Remove a row from Table using angular js?
NickName:Tanwer Ask DateTime:2017-11-06T15:27:09

How to Remove a row from Table using angular js?

I am using Angular http service to perform a DELEET operation , Its working fine , after deleting the data record I have to remove that row also from table .

Below is my code for all that

$scope.DeleteSchedule = function (recordId) {
   var v =$window.confirm('Are you sure you want to delete ?');
   if (v == true) {
       var row = '#row' + recordId;
       var table = 'table #tbl_Schedule_Delete tr ' + row;
       $http({
           url: '@Url.Action("DeleteSchedule", "Admin")',
           method: "DELETE",
           params: {
               recordId: recordId
           }
       }).then(function mySuccess(response) {
           alert('Row Deleted Successfully');
           angular.element(document.querySelector(table)).remove();
           //$('table #tbl_Schedule_Delete tr' + row).remove();
       }, function myError(response) {
           $window.alert('Warning! It failed.');
       });
   }
}

Refrence to jQuery remove() seems to do nothing

value of variable table will be 'table #tbl_Schedule_Delete tr #row35'

angular.element(document.querySelector(table)).remove();

I checked console log and there is no error or warning . How to do this in angular JS

Update 1 : Below is Table Mark Up

<tr id="row34" role="row" class="odd">
<td id="delete34" class="sorting_1"> 
<a id="deletebtn_34" ng-click="DeleteSchedule('34')"><i class="fa fa-times fa-lg" aria-hidden="true" style="color:#e90029"></i></a>
</td>
<td>34</td>
<td>11956</td>
<td>Tota Ram</td>
<td>04-10-2017</td>
<td>02-12-2017</td>
<td>Haryana</td>
<td>Badaun</td>
<td>03-11-2017</td>
</tr>

Copyright Notice:Content Author:「Tanwer」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/47131796/how-to-remove-a-row-from-table-using-angular-js

Answers
Jasper Seinhorst 2017-11-06T10:06:48

I wouldn't delete the row using angular.element but show/hide the row with ng-if of ng-show.\n\n<tr id=\"row34\" role=\"row\" class=\"odd\" ng-show=\"!deleted[34]\">\n\n\nin combination with:\n\nafter deletion in your controller:\n\nscope.deleted[recordId] = true;\n",


More about “How to Remove a row from Table using angular js?” related questions

How to Remove a row from Table using angular js?

I am using Angular http service to perform a DELEET operation , Its working fine , after deleting the data record I have to remove that row also from table . Below is my code for all that $scope.

Show Detail

Can not remove the expected row from table using Angular.js

I have an issue.I need to remove one particular row from table structure of my app using Angular.js.My code is present inside the below plunkr link. code is present here In the above code create ...

Show Detail

Scroller move to top of table when remove row from data table jquery plugin

I am using data table in my angular js Application as angular Directive and passing data to it using "=" scope.When remove row using row.remove.draw() scroller moves to top of table. This is my cod...

Show Detail

How to remove specific row in table using js

I am learning javascript and i made this simple page where you add your title and author. By clicking on add button the input is entered to table where you have remove button. How can i implement a

Show Detail

How to remove particular row in my table using with Angular.js?

I am checking two check boxes in first table those records are adding in second table this is fine. But if unchecked record removing as improper way, how can I remove exact row I unchecked. va...

Show Detail

Hideable Table Row using Angular JS

How to achieve a hideable Table Row in Angular JS ? I need to display a Database Table A , and on click of Table A's record , it shows a one to many mapping from Table B [going by A's Primary IDN...

Show Detail

how to remove an element in angular js?

I have to remove div element from the grid footer. how to remove using angular js.I have code like myGrid.html &lt;div class="row-fluid"&gt; &lt;div class="span12"&gt; &lt;div style="h

Show Detail

Angular Material Table | Add Remove rows at runtime

I am using Angular Material Table that is backed by a plain array as the data source. this.employees = this.route.snapshot.data.employes; // of type Employee[] resolved using a Resolve guard this.

Show Detail

how to clone table row with one way binding in angular js

i'm new to angular js. i'm need to add new row in table to get different values from textbox. i am using custom directive with transclude template. New row is added but all textbox binding same value

Show Detail

How to delete a particular row properly using Angular.js/Javascript

i need one help.I need to remove a particular row from a table using Angular.js .Here i have + and - button implementation.I have all my code inside https://plnkr.co/edit/D3UrDYwiglMKQyCW0wvW?p=pre...

Show Detail