[英]Angular Browser History back without reload previous page
i have a AngularJS app with list of items and the detail of the item. 我有一个带有项目列表和项目详细信息的AngularJS应用。
If I do some changes in detail and I want to return to list , list is already created again via remote request. 如果我做了一些详细的更改,并且想返回到list,则已经通过远程请求再次创建了list。
What is the best practice to stop reloading page after return from detail? 从详细信息返回后停止重新加载页面的最佳实践是什么?
I tried to solve it via this topic: 我试图通过以下主题解决它:
angularjs getting previous route path angularjs获取以前的路径
But without luck. 但是没有运气。
In list I'm using: 在列表中,我正在使用:
data-ng-controller="UsersCtrl" data-ng-init="initGrid()"
I think that problem is here. 我认为这个问题就在这里。
Thanks for any advice and simple example. 感谢您的建议和简单示例。
The recommended approach here is to use services to provide the data so that you can serve up the same data when you return to the controller. 此处推荐的方法是使用服务来提供数据,以便在返回控制器时可以提供相同的数据。
Your service should maintain the state of the previous view so that you can re-populate the scope when the controller is re-instantiated. 您的服务应保持先前视图的状态,以便在重新实例化控制器时可以重新填充作用域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.