angularjs点击图片放大实现上传图片预览
本文实例为大家分享了angularjs点击图片放大预览的具体代码,供大家参考,具体内容如下
承接上一篇文章
/*图片点击放大再点击还原*/ angular.module('routerModule').directive('enlargePic',function(){//<span style="font-family: Arial, Helvetica, sans-serif;">enlargePic指令名称,写在需要用到的地方img中即可实现放大图片</span> return{ restrict: "AE", link: function(scope,elem){ elem.bind('click',function($event){ var img = $event.srcElement || $event.target; angular.element(document.querySelector(".mask"))[0].style.display = "block"; angular.element(document.querySelector(".bigPic"))[0].src = img.src; }) } } }) .directive('closePic',function(){ return{ restrict: "AE", link: function(scope,elem){ elem.bind('click',function($event){ angular.element(document.querySelector(".mask"))[0].style.display = "none"; }) } } });
效果图:
相关推荐
songshijiazuaa 2020-09-24
bbccaaa 2020-07-28
newcome 2020-04-29
Web全栈笔记 2020-05-03
vs00ASPNET 2020-04-29
jinxiutong 2020-04-23
cuiwenjie 2020-04-18
chouliqingke 2020-02-13
breakpoints 2020-01-29
poplpsure 2019-12-28
nxcjh 2020-01-03
tiankele0 2020-01-05
H女王范儿 2019-12-29
且听真言 2019-12-21
前端架构师 2019-12-19
webgm 2019-10-25