zoukankan      html  css  js  c++  java
  • angularJS——利用theParam实现缓存功能

    需求:列表页分页,跳转详情页时,保存当前页数和搜索关键词。从详情页返回时,回到之前页数并搜索同一关键词。

    js:

    mainApp.factory('theParam', function() {
        return {
            currentPage : 1,pageSize : 12,param:''
        };
    });
    
    mainApp.controller('listController', function($scope, $http,theParam) {
        
        $scope.currentPage = theParam.currentPage;
        $scope.pageSize = theParam.pageSize;
        $scope.param = theParam.param; //搜索词
    
        $scope.dataList;
        var dataObj = new Object(),
            reqUrl = "****";
        var initObj = function(){
            dataObj.pageNumber = $scope.currentPage;
            dataObj.pageSize = $scope.pageSize;
            dataObj.param = $scope.param;
        }

      //*****省略其他******
    //以跳转指定页数为例 $scope.goXpage = function(x) { initObj();
         dataObj.pageNumber = x;
    theParam.param = $scope.param; //保存关键词 $http({ method : 'get', params : { param : $.toJSON(dataObj) }, data : {}, url : reqUrl }) .success(function(response, status, headers, config) {var rstate = response.result; if (rstate == "0") { var _data = response.message; $scope.dataList = _data.glist; $scope.currentPage = _data.pageNumber; theParam.currentPage = _data.pageNumber; //保存页数
           }
        else{ Showbo.Msg.alert('fail: '+response.error); } }) .error(function(response, status, headers, config) { Showbo.Msg.alert('error: '+response.error); }); }; }
  • 相关阅读:
    C++中智能指针的设计和使用
    [转]C++ 智能指针详解
    C++ const 常量和常指针
    深入理解C++中的mutable关键字
    C++ 静态常量
    BZOJ 1875: [SDOI2009]HH去散步
    BZOJ 1024: [SCOI2009]生日快乐
    BZOJ 1059: [ZJOI2007]矩阵游戏
    bzoj 1833: [ZJOI2010]count 数字计数
    LUOGU P2587 [ZJOI2008]泡泡堂
  • 原文地址:https://www.cnblogs.com/linjiangxian/p/12123270.html
Copyright © 2011-2022 走看看