angularjs点击图片放大实现上传图片预览

/*图片点击放大再点击还原*/ angular.module('routerModule').directive('enlargePic',function(){//<span>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"; }) } } });

效果图:

angularjs点击图片放大实现上传图片预览

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwzjzg.html