触发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",
   });
}

 

posted @ 2018-07-19 15:33  疯子不需要风  阅读(200)  评论(0)    收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示