angular动态删除ng-repaeat添加的dom节点的方法

本文介绍了angular动态删除ng-repaeat添加的dom节点的方法,分享给大家供大家参考,具体如下:

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

angular动态删除ng-repaeat添加的dom节点的方法_第1张图片

html代码如下:

//通过ng-repeat迭代创建dom
姓名 学历 专业 工作时间 工作经历
{{x.name}} {{x.education}} {{x.major}} {{x.workYear+'年'}} {{x.workExperience}}

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);//截取数组,删除当前行
    });
  }
});

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

你可能感兴趣的:(angular动态删除ng-repaeat添加的dom节点的方法)