如何解决Angular 6中的本地存储问题?

时间:2019-05-12 11:40:19

标签: javascript angular angular5 local-storage

我想在标题的每一行的编辑页面中显示行的名称。

我尝试使用localStorage设置密钥并使用进入编辑页面。

Listview.ts文件。传递行名进行编辑

 if (element.name) {
      this.dataService.pageName = element.name;
      this.dataService.setLocalStorage(environment.localStorageKeys.PAGENAME, element.name);
    }

公共数据服务文件

pageName = this.getLocalStorage(environment.localStorageKeys.PAGENAME)
    ? this.getLocalStorage(environment.localStorageKeys.PAGENAME)
    : '';

在编辑页面上获取数据

this.inviteCodeCrud[ 'page' ][ 'label' ]= 
 'edit' + ' for ' + this.dataService.pageName 

在编辑页面上,它必须显示为 当我第一次进入该行列表中的模块时,“ Edit for ram”工作正常,但是当我返回列表并再次返回另一行时,编辑会继续添加,例如“ Edit for ram for Shyam”并不断添加,一旦我重新加载页面,它就可以正常工作,但在角度路由中不会发生

0 个答案:

没有答案