RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
使用AngularJS怎么实现一个拖拽功能

本篇文章给大家分享的是有关使用AngularJS怎么实现一个拖拽功能,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

贡山ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联建站的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

具体如下:



  
    
    www.jb51.net AngularJS拖拽
    
  
  
      
      
                     var app = angular.module('myApp',[]);       //自定义属性       app.directive("weiYi",function(){         return{           restrict :'A',//A属性,E标签,C类名,D注释           link :function(scope,element,attr){             attr.data=angular.equals(attr.data,"true");             //console.log(attr.data);             console.log(element);             element.on("mousedown",function(e){               var that = $(this);               console.log(attr.data);               if(attr.data){                 $div=$("
");                 console.log($div);                 $div.css({"width":"100px","height":"100px","border": "2px dotted green","position":"absolute","left":that.offset().left,"top":that.offset().top});                 $div.appendTo($("body"));               }               var x=e.clientX-$(this).offset().left;               var y=e.clientY-$(this).offset().top;               //console.log(x+":"+y);               $(document).on("mousemove",function(e){                 if(attr.data){                   $div.css({"left":e.clientX-x,"top":e.clientY-y});                 }else{                   that.css({"left":e.clientX-x,"top":e.clientY-y});                 }               });               $(document).on("mouseup",function(e){                 //console.log($div);                 $(document).off();                 if(attr.data){                   that.css({"left":$div.offset().left,"top":$div.offset().top});                   $div.remove();                 }               })             })           }         }       });       app.controller('show',['$scope',function(scope$){       }]);        

以上就是使用AngularJS怎么实现一个拖拽功能,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。


分享标题:使用AngularJS怎么实现一个拖拽功能
网址分享:http://cqwzjz.cn/article/iiojoo.html