本地存储值被覆盖

时间:2018-09-16 09:35:21

标签: angular2-localstorage

我在打字稿函数中启动了2个本地存储变量。保存该值的第二个变量将覆盖第一个变量。我如何解决它?

OnSelectedOppPropStatsChange(TypeId:string,StrSelectedValue:string):void {

this.appService.SetLoadingShow(true);

var url = this.configs.DashboardDemandStatsURL();

var Input = {

  "TypeId": TypeId,

  "PS_No": this.user.PS_No,

  "StrSelectedValue": StrSelectedValue

};



localStorage.setItem(this.strTypeSelected, StrSelectedValue);

localStorage.setItem(this.strTypeIdValue, TypeId);



this.appService.GetDataFromAPIPost(url, Input)

  .then(response => {

    this.appService.SetLoadingShow(false);

    if (response.ResponseCode == this.configs.RetCodeFailure()) {

      this.ShowDemandDetails = false;

      this.errorMessage = response.ResponseData;

      this.appService.ShowMessagePopup(this.configs.MESSAGETYPEERROR(), this.errorMessage);

    }

    else {



      this.OpenDemandStatsDetails = JSON.parse(response.ResponseData.strDemandStatsOpen);

      this.TeamFulfilledStatsDetails = JSON.parse(response.ResponseData.strDemandStatsTeam);

      this.RPMFulfilledStatsDetails = JSON.parse(response.ResponseData.strDemandStatsRPM);



      this.TotalRRCount = this.OpenDemandStatsDetails.length + this.TeamFulfilledStatsDetails.length + this.RPMFulfilledStatsDetails.length;

    }



  },

    error => { this.errorMessage = <string>error; this.appService.SetLoadingShow(false) });

}

OnClickOpenRRNavigate():无效{

let SelectedItem = localStorage.getItem(this.strTypeSelected);

let SelectedType = localStorage.getItem(this.strTypeIdValue);



this.appService.SetLoadingShow(true);

var url = this.configs.DashboardDemandStatsTableURL();

var Input = {

  "TypeId": SelectedType,

  "PS_No": this.user.PS_No,

  "StrSelectedValue": SelectedItem,

  "strRRAllocationValue": this.StrOpenValue

};



this.appService.GetDataFromAPIPost(url, Input)

  .then(response => {

    this.appService.SetLoadingShow(false);

    if (response.ResponseCode == this.configs.RetCodeFailure()) {

      this.errorMessage = response.ResponseData;

      this.appService.ShowMessagePopup(this.configs.MESSAGETYPEERROR(), this.errorMessage);

    }

    else {



      this.DemandTableDetails = JSON.parse(response.ResponseData.strDemandStatsTable);

      this.ShowDemandTable = true;

    }



  },

    error => { this.errorMessage = <string>error; this.appService.SetLoadingShow(false) });

}

在函数OnClickOpenRRNavigate()中,SelectedType和SelectedItem保持相同的值。我该如何解决?

0 个答案:

没有答案