ionic局部刷新页面与刷新整个页面

时间:2023-03-09 06:49:06
ionic局部刷新页面与刷新整个页面

1.全局刷新,禁用缓存;

  在app.js中设置cach:false,如下:

.state('material', {
url: '/material',
cache:false,
templateUrl: 'templates/commonusefunction/material.html',
resolve: load([
'js/controllers/commonusefunction/materialController.js',
])
})

2.局部刷新页面,加载一部分数据的情况:

  在页面的控制器中加入:

$scope.$on('$ionicView.beforeEnter', function() {
if($scope.userid != $localStorage.get("loginID")){
$scope.userid=$localStorage.get("loginID");
$scope.unitlist=null;
$scope.data=null;
$scope.getUnit();
$scope.searchClick();
}
});