【发布时间】:2015-07-17 08:29:12
【问题描述】:
我想做类似的事情:
1. Set $scope.val = <Some dynamic data>
2. Click a link and be routed to a new template (with the same controller).
3. $scope.val should still be the same value as it was on the last page.
以某种方式为范围持久化数据是解决此问题的正确方法,还是有其他方法?您甚至可以创建一个在路由之间具有持久范围的控制器,当然除了将其保存在数据库中。
【问题讨论】:
-
不在数据库中,但 cookie 或 localStorage 可以提供帮助
-
嗨,Nimesh,你发现了吗?一个 js fiddle 或一个 plunker 会有所帮助。
标签: angularjs controller routes scope angular-routing