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); }); }; }
  • 相关阅读:
    接口测试基础
    python学习笔记(一)
    Charles学习笔记
    接口测试笔记
    【CSS】Beginner5:Margins&Padding
    【CSS】Beginner4:Text
    【CSS】Beginner3:Color
    【CSS】Beginner2:Selectors, Properties, and Values
    【CSS】Beginner1:Applying CSS
    【HTML】Beginner9:Form
  • 原文地址:https://www.cnblogs.com/linjiangxian/p/12123270.html
Copyright © 2011-2022 走看看