I have two html pages. First page being a list of patients each being a hyperlink. The expected behavior is that, on click of a hyperlink ( corresponding to a patient), the user should be redirected to another html page which has the details of the corresponding patient. The redirection is happening. But, I am not able to pass the data from the first html page to the second one.
我有两个html页面。第一页是患者列表,每个都是超链接。预期的行为是,单击一个超链接(对应于一个病人),应该将用户重定向到另一个包含相应病人详细信息的html页面。重定向。但是,我不能将第一个html页面的数据传递给第二个html页面。
2 个解决方案
#1
2
There are plenty of way to do that:
有很多方法可以做到:
- localStorage of the browser (angular plugin)
- 浏览器的本地存储(角插件)
- URL parameters (angular $location)
- URL参数(角位置美元)
- Server-side session
- 服务器端会话
- Cookies, outdated and inefficient nowadays, better go for #1 (using cookies with angular)
- 饼干,过时和低效的现在,最好选择1(使用有棱角的饼干)
Best applicable implementation depends on your architecture on front/back
最佳适用的实现取决于您的体系结构
#2
1
The URL should contain an ID for the item you want to display, e.g. /patient/432
.
URL应该包含要显示的项目的ID,例如/patient/432。
Using that ID, the second page loads the data.
使用该ID,第二个页面加载数据。
If you are using Angular, and both pages are in fact part of a single app, you would use a Service that caches the data. That is, the service loads your patients list and returns either a list or a single item from the list. That way, you don't have to load the individual items from the server API each time.
如果您使用的是角度,而且这两个页面实际上都是一个应用程序的一部分,那么您将使用缓存数据的服务。也就是说,该服务加载您的患者列表,并从列表中返回列表或单个项目。这样,您就不必每次都从服务器API加载各个项目。
#1
2
There are plenty of way to do that:
有很多方法可以做到:
- localStorage of the browser (angular plugin)
- 浏览器的本地存储(角插件)
- URL parameters (angular $location)
- URL参数(角位置美元)
- Server-side session
- 服务器端会话
- Cookies, outdated and inefficient nowadays, better go for #1 (using cookies with angular)
- 饼干,过时和低效的现在,最好选择1(使用有棱角的饼干)
Best applicable implementation depends on your architecture on front/back
最佳适用的实现取决于您的体系结构
#2
1
The URL should contain an ID for the item you want to display, e.g. /patient/432
.
URL应该包含要显示的项目的ID,例如/patient/432。
Using that ID, the second page loads the data.
使用该ID,第二个页面加载数据。
If you are using Angular, and both pages are in fact part of a single app, you would use a Service that caches the data. That is, the service loads your patients list and returns either a list or a single item from the list. That way, you don't have to load the individual items from the server API each time.
如果您使用的是角度,而且这两个页面实际上都是一个应用程序的一部分,那么您将使用缓存数据的服务。也就是说,该服务加载您的患者列表,并从列表中返回列表或单个项目。这样,您就不必每次都从服务器API加载各个项目。