您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“angular中如何動態(tài)刪除ng-repaeat添加的dom節(jié)點”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學習一下“angular中如何動態(tài)刪除ng-repaeat添加的dom節(jié)點”這篇文章吧。
具體如下:
通過點擊刪除按鈕刪除數(shù)據(jù)庫信息以及當前行
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">專業(yè)</th> <th> <i class="ace-icon fa fa-clock-o bigger-110 hidden-480"></i> 工作時間 </th> <th class="hidden-480">工作經(jīng)歷</th> <th></th> </tr> </thead> <tbody> <tr ng-repeat="x in jl" class="hang">//通過ng-repeat迭代創(chuàng)建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-success"> <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-success" 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 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);//截取數(shù)組,刪除當前行 }); } });
以上是“angular中如何動態(tài)刪除ng-repaeat添加的dom節(jié)點”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。