素材巴巴 > 程序开发 >

angularJS实现动态添加,删除div

程序开发 2023-09-03 14:40:33

要实现的功能类似下图,动态添加或者删除div

点击 增加可添加一条div  点击删除可删除一条div










HTML代码如下:(省略CSS样式代码了大笑


授权给:Open/DownloadView PermissionsEdit Permissions


添加和删除的JS代码分别如下:

//增加许可访问div
 $scope.permissions = [{grantee: "",port1:"",port2:"",port3:""}];
 $scope.addPermission = function($index){$scope.permissions.splice($index + 1, 0,{grantee:"", port1:"",port2:"",port3:""});
 }//删除许可访问div
 $scope.delPermission = function($index){$scope.permissions.splice($index, 1);
 }



标签:

素材巴巴 Copyright © 2013-2021 http://www.sucaibaba.com/. Some Rights Reserved. 备案号:备案中。