如何在angularJS中将数据从一个html页面传递到另一个页面?

时间:2016-03-30 11:20:54

标签: angularjs

我有两个html页面。第一页是患者列表,每个患者都是超链接。预期的行为是,在点击超链接(对应于患者)时,应该将用户重定向到具有相应患者的细节的另一个html页面。重定向正在发生。但是,我无法将数据从第一个html页面传递到第二个页面。

2 个答案:

答案 0 :(得分:2)

有很多方法可以做到:

  1. 浏览器的localStorage(angular plugin
  2. 网址参数(angular $location
  3. 服务器端会话
  4. 现在的Cookie过时且效率低下,最好去#1(using cookies with angular
  5. 最佳适用实施取决于您前/后的架构

答案 1 :(得分:1)

网址应包含您要显示的项目的ID,例如Dim objWMIService, objProcess, colProcess,WshShell Dim strComputer, strList strComputer = "." Set WshShell = WScript.CreateObject("WScript.Shell") Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process") dim counter counter=0 dim newid For Each objProcess in colProcess if objProcess.Name = "notepad.exe" and objProcess.processID<>newid then counter=counter+1 if counter=1 then Dim fso, MyFile Set fso = CreateObject("Scripting.FileSystemObject") strPath = WshShell.SpecialFolders("Desktop")&"\"&serial&".txt" Set MyFile = fso.CreateTextFile(strPath, True) MyFile.Close Set EngineRun = WshShell.exec("notepad.exe " & strPath) newid=EngineRun.ProcessID WshShell.AppActivate(newid) end if 'msgbox objProcess.processID WshShell.AppActivate (objProcess.processID) WScript.Sleep 500 WshShell.sendkeys "% r" WScript.Sleep 500 WshShell.sendkeys "%E" ' edit WScript.sleep 500 WshShell.sendkeys "a" WScript.sleep 500 WshShell.sendkeys "%E" ' edit WScript.sleep 500 WshShell.sendkeys "c" WScript.sleep 500 WScript.sleep 500 WshShell.sendkeys "%F" ' edit WScript.sleep 500 WshShell.sendkeys "x" WScript.sleep 500 WshShell.sendkeys "n" WScript.sleep 500 WshShell.AppActivate (newid) WScript.sleep 500 WshShell.sendkeys vbNewLine & " --- " & objProcess.CommandLine & " --- " & vbNewLine WScript.sleep 500 WshShell.sendkeys "%E" ' edit WScript.sleep 500 WshShell.sendkeys "p" end if Next WshShell.AppActivate (newid) WScript.sleep 500 WshShell.sendkeys "%F" ' edit WScript.sleep 500 WshShell.sendkeys "s" WScript.sleep 500 WScript.sleep 500 WshShell.sendkeys "%F" ' edit WScript.sleep 500 WshShell.sendkeys "x" WScript.sleep 500 function serial() strSafeDate = DatePart("yyyy",Date) & Right("0" & DatePart("m",Date), 2) & Right("0" & DatePart("d",Date), 2) strSafeTime = Right("0" & Hour(Now), 2) & Right("0" & Minute(Now), 2) & Right("0" & Second(Now), 2) strDateTime = strSafeDate & strSafeTime serial=strDateTime end function

使用该ID,第二页加载数据。

如果您使用的是Angular,并且这两个页面实际上都是单个应用程序的一部分,那么您将使用缓存数据的服务。也就是说,该服务加载患者列表并从列表中返回列表或单个项目。这样,您每次都不必从服务器API加载单个项目。