到 $routeProvider 或 $stateProvider [英] to $routeProvider or $stateProvider

查看:27
本文介绍了到 $routeProvider 或 $stateProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找解决这个困境的合理答案,无论是否选择 routeProvider.

I have been looking for a sound answer to to this dilema, to routeProvider or not to.

看起来好像 $routeProvider 很快就会停止使用并替换为 $stateProvider 不幸的是我不知道这个声明的准确性加上 stateProvider 仍然只能通过 ui_router 插件获得.

It appears as if $routeProvider is soon going to be discontinued and replace with $stateProvider unfortunately I don't know the accuracy of this statement plus stateProvider is still only available via ui_router plugin.

是否计划将 stateProvider 添加为 AngularJS Core 的一部分?假设它将很快取代旧的 $routeProvider 是否省心?

Is the plan to add stateProvider as part of the AngularJS Core? Is it save to assume that it will soon replace the old $routeProvider?

它们当然不能很好地协同工作,而且我在 github 中找到的迁移 CI 不起作用并且缺乏文档.

They certainly don't play well together and the migration CI that I found in github doesn't work and lacks documentation.

推荐答案

经过很长时间,我们决定硬着头皮从 1.1.1 迁移到 1.2.与此同时,我们意识到 $routerProvider 的真正有限,所以我们选择了 ui-router.到目前为止,我们喜欢它,它允许您在视图中进行一些复杂的嵌套,并为您的应用程序添加更多结构,例如,在 $stateProvider 中,您可以定义 onEnter 和 onExit,这允许您修改数据并恢复它退出时,您还可以过渡到状态,这是非常强大的.我会投票支持 ui-router 成为 Angular 核心的一部分,甚至取代 $routeProvider.我希望这能帮助你下定决心.如果您有一个基本的应用程序或演示页面,$routeProvider 仍然有效.

After a very long time we decided to bite the bullet and migrate from 1.1.1 to 1.2. At the same time we realized how limited $routerProvider really is so we went with ui-router. So far, we love it, it allows you to do some complex nesting in the views plus add a bit more structure to your app, for example, in $stateProvider you can define onEnter and onExit which allows you to modify your data and restore it upon exiting, you can also transitionTo state which is extremely powerful. I would vote for ui-router to be part of Angular core and even replace $routeProvider. I hope this helps you made up your mind. $routeProvider still works, if you have a basic app or demo page.

这篇关于到 $routeProvider 或 $stateProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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