返回Angular浏览器历史记录而无需重新加载上一页 [英] Angular Browser History back without reload previous page

查看:274
本文介绍了返回Angular浏览器历史记录而无需重新加载上一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个AngularJS应用,其中包含项目列表和项目详细信息.

i have a AngularJS app with list of items and the detail of the item.

如果我做了一些详细的更改,并且想返回list,则已经通过远程请求再次创建了list.

If I do some changes in detail and I want to return to list , list is already created again via remote request.

从详细信息返回后停止重新加载页面的最佳实践是什么?

What is the best practice to stop reloading page after return from detail?

我试图通过以下主题解决它:

I tried to solve it via this topic:

angularjs获取先前的路由路径

但是没有运气.

在我正在使用的列表中:

In list I'm using:

data-ng-controller="UsersCtrl" data-ng-init="initGrid()"

我认为问题就在这里.

感谢您提供任何建议和简单示例.

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.

这篇关于返回Angular浏览器历史记录而无需重新加载上一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆