触发ionic弹窗区域外的方法
最近项目需要在页面弹窗的时候需要点击弹窗区域外的地方,其实也就是点击页面HTML就可以关闭弹窗,
首先在controller通过js获取到html的dom节点,然后绑定点击事件,话不多说上代码:
var htmlEl = angular.element(document.querySelector('html'));
htmlEl.on('click', function (event) {
if (event.target.nodeName === 'HTML') {
if (myPopup) {
myPopup.close();
}
}
});
var myPopup;
$scope.myPP=function(){
myPopup=$ionicPopup.show({
template:"Hello world",
scope:$scope,
title:"Tips",
});
}

浙公网安备 33010602011771号