简体   繁体   English

如何使用 Angular 将 ID 一页传递到另一页?

[英]How to Pass ID one page to another page using Angular?

My question is, do I want to pass the id from one page to another page?我的问题是,我想将 id 从一页传递到另一页吗? without using Routing and local storage.不使用路由和本地存储。 if we stored in the service file, once refresh the page.如果我们存储在服务文件中,一旦刷新页面。 it is collapsed, so, please tell me the possible ways.它被折叠了,所以,请告诉我可能的方法。

Thanks谢谢

There are many ways by which you can have state management and share your state across different components您可以通过多种方式管理 state 并在不同组件之间共享您的 state

  • Using Services使用服务
  • State Management library like NgRx State 管理库,如NgRx

But all this ways will lose the data when you reload the page, so to handle that situation you have to take additional steps但是当您重新加载页面时,所有这些方式都会丢失数据,因此要处理这种情况,您必须采取额外的步骤

  • For Services: You can store the data in local/session storage and maintain them as per security requirements对于服务:您可以将数据存储在本地/会话存储中并根据安全要求进行维护
  • For NgRx: You can use a library or write your own functionality leveraging local/session storage对于 NgRx:您可以使用库或编写自己的功能,利用本地/会话存储

You can also leverage your backend for storing data based on your application requirements您还可以根据应用程序要求利用后端存储数据

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用角度片段将数据从一个页面传递到另一个页面? - How to pass data from one page to another page using angular fragments? 如何在同一页面中将 id(Parameter ) 从一个地方传递到另一个地方? - How to pass id(Parameter ) from one place to another in same page? 如何在Angular中将值从一页传递到另一页? - How to pass the value from one page to another in Angular? 如何使用Ionic 3和NavController使用Angular 4将数据从一页传递到另一页。 我需要传递第一页到第二页的输入并调用API - How to pass data from one page to another page using Ionic 3 and Angular 4 using NavController. I need to pass input of 1st to 2nd page and callAPI 如何使用表单发布方法将参数从简单的 html 页面传递到另一个角度页面? - How to pass parameter from simple html page to another angular page using form post method? 在 angular 10 中将变量从一页传递到另一页 - pass variable from one page to another in angular 10 在 angular 离子中将参数从一页传递到另一页 - pass params from one page to another in angular ionic 如何将数据从一页发送到另一页? 使用离子和 angular - How to send the data from one page to another page? using ionic and angular 如何将带有 id 的数组从一个组件传递到另一个组件(角度) - How to pass an array with id's from one component to another (angular) 如何使用Angular2将表单页面中的某些值传递给另一个 - How To pass Some value from a form page To another using Angular2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM