本文实例为大家分享了angularjs点击图片放大预览的具体代码,供大家参考,具体内容如下
图片点击放大再点击还原*/
angular.module('routerModule').directive('enlargePic',function(){//名称,写在需要用到的地方img中即可实现放大图片
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",function($event){
angular.element(document.querySelector(".mask"))[0].style.display = "none";
})
}
}
});
效果图:
@H_502_11@
原文链接:https://www.f2er.com/js/41309.html