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";
})
}
}
});
效果图:
以上是 angularjs点击图片放大实现上传图片预览 的全部内容, 来源链接: utcz.com/z/329638.html