repaeat添加的dom节点的方法

通过点击删除按钮删除数据库信息以及当前行

repaeat添加的dom节点的方法

html代码如下:

<div> <div> <!-- PAGE CONTENT BEGINS --> <div> <div> <table> <thead> <tr> <th>姓名</th> <th>学历</th> <th>专业</th> <th> <i></i> 工作时间 </th> <th>工作经历</th> <th></th> </tr> </thead> <tbody> <tr ng-repeat="x in jl">//通过ng-repeat迭代创建dom <td> <a href="#" >{{x.name}}</a> </td> <td>{{x.education}}</td> <td>{{x.major}}</td> <td>{{x.workYear+'年'}}</td> <td> {{x.workExperience}} </td> <td> <div> <button> <i></i> </button> <button> <i></i> </button> <button ng-click="_delete($index)"> <i></i> </button> <button> <i></i> </button> </div> <div> <div> <button data-toggle="dropdown" data-position="auto"> <i></i> </button> <ul> <li> <a href="#" data-rel="tooltip" title="View"> <span> <i></i> </span> </a> </li> <li> <a href="#" data-rel="tooltip" title="Edit"> <span> <i></i> </span> </a> </li> <li> <a href="#" data-rel="tooltip" title="Delete"> <span> <i></i> </span> </a> </li> </ul> </div> </div> </td> </tr> </tbody> </table> </div><!-- /.span --> </div><!-- /.row --> <!-- PAGE CONTENT ENDS --> </div><!-- /.col --> </div> <!-- /.row -->

js代码如下:

angular.controller('tables',function ($scope,$http) { $http({ method: 'GET', url:'resumes/myResume/'+USER.id }).then(function success(rep) { $scope.jl=rep.data; }); $scope._delete=function (idx) { $scope.id=$scope.jl[idx].id; $http({ method:'DELETE', url:'resumes/'+$scope.id }).then(function success(rep) { $scope.jl.splice(idx, 1);//截取数组,删除当前行 }); } });

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyjjdf.html