如何从一个控制器传递日期值到另一个角度UI路由 [英] How to pass date value from one controller to another in angular ui routing

查看:108
本文介绍了如何从一个控制器传递日期值到另一个角度UI路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过采用了棱角分明 UI 路由其中用户选择在一个网页到另一个网页的日期值。有事先这些controllers.Thanks之间不存在父子关系。

I want to pass the date value which the user selects in one page to another page using angular UI routing. There is no parent child relationship between these controllers.Thanks in advance

推荐答案

最佳实践

您应该创建getter和setter方法​​为您希望共享的数据的服务,您可以实例化你想之间共享数据控制器这些服务。

You should create a service with setters and getters for the data that you want to share, you can then instantiate these services in the controllers you wish to share data between.

这可以让你安全地在两者之间移动数据。

This lets you safely move data between the two.

替代

如果你想快速和肮脏的方式控制器之间太共享数据,然后使用$ rootScope,它作为一个全局变量,但请记住,有与这些变量的问题,请参阅<一个href=\"http://stackoverflow.com/questions/10525582/why-are-global-variables-considered-bad-practice-javascript\">here

If you want a quick and dirty way too share data between controllers then use $rootScope, it acts as a global variable but remember that there are problems with these variables see here

这篇关于如何从一个控制器传递日期值到另一个角度UI路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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