标签:cat user win scroll str layer class func control
$scope.$on("$destroy", function() { //清除配置,不然scroll会重复请求 })
在Controller中监听$destory事件,这个事件会在页面发生跳转的时候触发。
在页面跳转之后,这个页面监听的一些全局事件,比如window.scroll事件在下一页scroll的时候还会继续被触发
在这个事件的回调中,清除当前页面的监听或者一些参数保证下面的页面不会再触发当前页面的事件回调
【举个栗子】
controller:‘UserInfo‘
//验证必填信息
$scope.$on("$destroy", function() {
if(!$scope.currentUser.telephone || !$scope.currentUser.address){
layer.alert("请将个人信息补充完整");
$location.path("userInfo");
}
})
标签:cat user win scroll str layer class func control
原文地址:http://www.cnblogs.com/miny-simp/p/7133618.html