我可以在角度路由时传递数据(can I pass data when routing in angular)

编程入门 行业动态 更新时间:2024-10-21 13:36:44
我可以在角度路由时传递数据(can I pass data when routing in angular)

我希望在以角度路由到新控制器时传递大量数据( json )。 在控制器AI中调用$location.path('/B'); 然后将路由到控制器B. 我知道我可以在url中传递参数,但是我有很多数据。 角度可以做类似'POST'方法并以这种方式传递数据吗?

I want to pass a lot of data (json) when routing to a new controller in angular. In controller A I call $location.path('/B'); which in turn will route to controller B. I know I can pass parameter in the url itself, but I have a lot of data. Can angular do something similar to 'POST' method and pass data in this way?

最满意答案

没有必要打扰像角度这样的行为。

您有几种方法可以做到这一点:

使用将跨页面加载保留数据的服务 传递真实的GET参数(当页面专门链接到此参数时,例如用于显示此对象详细信息的对象ID) 将数据存储在本地存储/会话存储中 使用控制器'resolve'功能在显示页面之前获取新数据(不是你想做什么......)

No need to bother with POST like behavior with angular.

You have several ways to do this :

use a service that will preserve data across page loads pass real GET argument (when the page is specifically linked to this argument, for example an object ID used to display this object details) store data in local storage / session storage use controller 'resolve' functionnality to fetch new data before displaying page (not what you want to do though...)

更多推荐

本文发布于:2023-08-04 08:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1413097.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   角度   数据   pass   routing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!