angularJS-实现内容添加或移除
来源:互联网 发布:易语言源码做成软件 编辑:程序博客网 时间:2024/06/05 06:10
<!DOCTYPE html><html ng-app="myPro"><head><meta charset="UTF-8"><title>angularJS-实现内容添加或移除</title><script src="js/angular.min.js"></script><script src="js/jquery-1.11.0.js" ></script></head><style>*{padding: 0;margin: 0;}ol,ul{list-style: none;}body{background-color: #414246;}.box{width: 500px;height: 300px;border: 1px solid #000000;margin: 100px auto;background-color: #373A3F;color: #A1A6A7;font-size: 12px;}.box .box-l{width: 45%;height: 100%;float: left;border-right: 1px solid #000000;}.box .box-l ul li{width: 91%;height: 20px;line-height: 20px; float: left;margin: 10px 0 0 20px;position: relative;}.box .box-l ul li input{float: left;margin: 3px 3px 0 0;opacity: 0;position: absolute;top: 3px;left: 5px;cursor:pointer;}.box .box-l ul li .pointCheck_icon{width: 15px;height: 15px;float: left;margin: 3px 5px 0 ;background: url(img/banner.jpg) -2px -43px no-repeat;}.box .box-l ul li input:hover+.pointCheck_icon{background-position: -22px -43px;}.box .box-l ul li .pointChecked_icon{background-position: -42px -43px !important;}.box .box-l p{float: left;}.box .box-m{width: 10%;height: 100%;float: left;border: 1px solid #000000;}.box .box-m p{width: 40px;height: 20px;line-height: 20px;text-align: center;border: 1px solid #000000;cursor: pointer;}.box .box-m p:nth-child(1){margin: 120px 0 0 3px;}.box .box-m p:nth-child(2){margin: 10px 0 0 3px;}.box .box-m p:hover{color: #ffffff;}.box .box-r{width: 44%;height: 100%;float: left;}.box .box-r ul li{width: 91%;height: 20px;line-height: 20px; float: left;margin: 10px 0 0 20px;position: relative;}.box .box-r ul li input{float: left;margin: 3px 3px 0 0;opacity: 0;position: absolute;top: 3px;left: 2px;cursor:pointer;}.box .box-r ul li .pointCheck_icon{width: 15px;height: 15px;float: left;margin: 3px 5px 0 ;background: url(img/banner.jpg) -2px -43px no-repeat;}.box .box-r ul li input:hover+.pointCheck_icon{background-position: -22px -43px;}.box .box-r ul li .pointChecked_icon{background-position: -42px -43px !important;}</style><body ng-controller="myProController"><div class="box"><div class="box-l"><ul><li ng-repeat="data in userInfos"><input type="checkbox" autocomplete="off" ng-model="data.checked" ng-click="pointAddClick(data.checked,data.title,data.channelId)"/><div class="pointCheck_icon" ng-class="{pointChecked_icon:data.checked}"></div><p>{{data.title}}</p></li></ul></div><div class="box-m"><p ng-click="add()">添加</p><p ng-click="delete()">移除</p></div><div class="box-r"><ul><li ng-repeat="data in channelList"><input type="checkbox" autocomplete="off" ng-model="data.checked" ng-click="pointDeleteClick(data.checked,data.title,data.channelId)"/><div class="pointCheck_icon" ng-class="{pointChecked_icon:data.checked}"></div><p>{{data.title}}</p></li></ul></div></div></body><script>var pro = angular.module('myPro',[]);pro.controller("myProController",["$scope",function($scope){var userInfo = [{"title":"用户11","channelId":"1"},{"title":"用户22","channelId":"2"},{"title":"用户33","channelId":"3"},{"title":"用户44","channelId":"4"},{"title":"用户55","channelId":"5"},{"title":"用户66","channelId":"6"},{"title":"用户77","channelId":"7"},{"title":"用户88","channelId":"8"},{"title":"用户99","channelId":"9"}];$scope.userInfos = userInfo;$scope.pointAddChannel = [];$scope.pointDeleteChannel = [];$scope.channelList = [];//左侧选中事件$scope.pointAddClick = function(checked,title,channelId){if(checked){$scope.pointAddChannel.push({title:title,checked:false,channelId:channelId});}else{angular.forEach($scope.pointAddChannel,function(i,index){if(i.channelId==channelId){$scope.pointAddChannel.splice(index,1);};});}};//右侧选中事件$scope.pointDeleteClick = function(checked,title,channelId){if(checked){$scope.pointDeleteChannel.push({title:title,checked:false,channelId:channelId});}else{angular.forEach($scope.pointDeleteChannel,function(i,index){if(i.channelId==channelId){$scope.pointDeleteChannel.splice(index,1);};});};};//添加按钮$scope.add = function(){angular.forEach($scope.pointAddChannel,function(i){var bool = true;angular.forEach($scope.channelList,function(j){if(i.channelId==j.channelId){bool = false;};});if(bool){$scope.channelList.push({title:i.title,checked:false,channelId:i.channelId});};});};//移除按钮$scope.delete = function(){angular.forEach($scope.pointDeleteChannel,function(i){angular.forEach($scope.channelList,function(j,index){if(i.channelId==j.channelId){$scope.channelList.splice(index,1);return false;};});});$scope.pointDeleteChannel=[];};}]);</script></html>
阅读全文
0 0
- angularJS-实现内容添加或移除
- angularjs 添加课程表+移除+不可重复添加
- 核心只要两行即可实现添加或移除className
- 如何:使用“添加引用”对话框添加或移除引用
- angularjs 移除定时器
- 如何:在 Visual Studio 中添加或移除引用
- Cocoa执行AppleScript添加或移除守护进程
- JavaScript 动态添加、移除元素或属性
- Matlab如何添加或移除子文件夹路径
- angularJS输入内容渲染添加
- 移除重复内容
- AngularJS 分页 点击当前页添加样式,其余移除样式
- AngularJs实现添加排序
- 添加&移除附件
- 通知的添加和移除通过block实现
- 实现View的添加和移除动画
- JQuery快速添加/移除插件EasyInsert的简单取值、自动添加或移除多行标签、自动添加事件
- angularjs添加数据展示或隐藏数据
- 正阅读微信小说分销系统-视频教程-4.数据统计 包含图文教程
- log4j
- Arduino/Microduino与OneNet平台及web服务器端的交互
- Java多线程同步的五种方法
- js正则表达式在(replace()方法)
- angularJS-实现内容添加或移除
- LSTM(一)之深入理解
- java内存与String类型详解
- 数组与矩阵---不重复打印排序数组中相加和为给定值的所有二元组和三元组
- 如何确定Kafka的分区数,key和consumer线程数,以及不消费问题解决
- Bootstrap插件(三)——标签页导航(tab.js)
- Android端用JDBC方法连接服务器端Mysql
- codeforces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- XGBoost简介