angular動態(tài)刪除ng-repaeat添加的dom節(jié)點(diǎn)的方法
更新時間:2017年07月20日 15:33:34 作者:HellowWorldZz
本篇文章主要介紹了angular動態(tài)刪除ng-repaeat添加的dom節(jié)點(diǎn)的方法,非常具有實(shí)用價值,需要的朋友可以參考下
本文介紹了angular動態(tài)刪除ng-repaeat添加的dom節(jié)點(diǎn)的方法,分享給大家供大家參考,具體如下:
通過點(diǎn)擊刪除按鈕刪除數(shù)據(jù)庫信息以及當(dāng)前行

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>學(xué)歷</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ù)組,刪除當(dāng)前行
});
}
});
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
AngularJS 打開新的標(biāo)簽頁實(shí)現(xiàn)代碼
本文通過實(shí)例代碼給大家介紹了angularJS 打開新的標(biāo)簽頁方法,代碼簡單易懂,非常不錯,具有參考借鑒價值,需要的朋友參考下吧2017-09-09
AngularJS定時器的使用與移除操作方法【interval與timeout】
這篇文章主要介紹了AngularJS定時器的使用與移除操作方法,結(jié)合實(shí)例形式分析了AngularJS中interval與timeout方法的相關(guān)使用技巧,需要的朋友可以參考下2016-12-12
Angular 13+開發(fā)模式慢的原因及構(gòu)建性能優(yōu)化解析
這篇文章主要為大家介紹了Angular 13+開發(fā)模式慢的原因及構(gòu)建性能優(yōu)化解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12

