angular动态删除ng-repaeat添加的dom节点的方法
网络编程 2021-07-04 18:32www.168986.cn编程入门
本篇文章主要介绍了angular动态删除ng-repaeat添加的dom节点的方法,非常具有实用价值,需要的朋友可以参考下
本文介绍了angular动态删除ng-repaeat添加的dom节点的方法,分享给大家供大家参考,具体如下
通过点击删除按钮删除数据库信息以及当前行
html代码如下:
<div class="row"> <div class="col-xs-12"> <!-- PAGE CONTENT BEGINS --> <div class="row"> <div class="col-xs-12"> <table id="simple-table" class="table table-bordered table-hover"> <thead> <tr> <th>姓名</th> <th>学历</th> <th class="hidden-480">专业</th> <th> <i class="ace-icon fa fa-clock-o bigger-110 hidden-480"></i> 工作时间 </th> <th class="hidden-480">工作经历</th> <th></th> </tr> </thead> <tbody> <tr ng-repeat="x in jl" class="hang">//通过ng-repeat迭代创建dom <td> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >{{x.name}}</a> </td> <td>{{x.education}}</td> <td class="hidden-480">{{x.major}}</td> <td>{{x.workYear+'年'}}</td> <td class="hidden-480"> {{x.workExperience}} </td> <td> <div class="hidden-sm hidden-xs btn-group"> <button class="btn btn-xs btn-suess"> <i class="ace-icon fa fa-check bigger-120"></i> </button> <button class="btn btn-xs btn-info"> <i class="ace-icon fa fa-pencil bigger-120"></i> </button> <button class="btn btn-xs btn-danger" ng-click="_delete($index)"> <i class="ace-icon fa fa-trash-o bigger-120"></i> </button> <button class="btn btn-xs btn-warning"> <i class="ace-icon fa fa-flag bigger-120"></i> </button> </div> <div class="hidden-md hidden-lg"> <div class="inline pos-rel"> <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto"> <i class="ace-icon fa fa-cog icon-only bigger-110"></i> </button> <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close"> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip-info" data-rel="tooltip" title="View"> <span class="blue"> <i class="ace-icon fa fa-search-plus bigger-120"></i> </span> </a> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip-suess" data-rel="tooltip" title="Edit"> <span class="green"> <i class="ace-icon fa fa-pencil-square-o bigger-120"></i> </span> </a> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip-error" data-rel="tooltip" title="Delete"> <span class="red"> <i class="ace-icon fa fa-trash-o bigger-120"></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 suess(rep) { $scope.jl=rep.data; }); $scope._delete=function (idx) { $scope.id=$scope.jl[idx].id; $http({ method:'DELETE', url:'resumes/'+$scope.id }).then(function suess(rep) { $scope.jl.splice(idx, 1);//截取数组,删除当前行 }); } });
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程