是什么在AngularJs $ routeProvider和$ stateProvider之间的区别 [英] What is the difference between $routeProvider and $stateProvider in AngularJs
问题描述
请解释之间的差异 $ routeProvider
和 $ stateProvider
在AngularJs。
Please explain the difference between $routeProvider
and $stateProvider
in AngularJs.
这是最好的做法。
推荐答案
角自己的NG-路由器采用网址
考虑而路由,UI的路由器采用状态
除了网址。
Angular's own ng-Router takes URLs
into consideration while routing, UI-Router takes states
in addition to URLs.
各国必须命名,嵌套和并行的意见,使您可以有力地管理应用程序的界面。
States are bound to named, nested and parallel views, allowing you to powerfully manage your application's interface.
而在NG-路由器,你必须通过&LT提供链接的时候要非常小心的URL; A HREF =>
标签,在UI的路由器你有只保留状态
的初衷。你像提供&LT链接;一个UI的SREF =>
。请注意,即使您使用< A HREF =>
在UI的路由器,就像你在NG-路由器做的,它仍然可以工作。
While in ng-router, you have to be very careful about URLs when providing links via <a href="">
tag, in UI-Router you have to only keep state
in mind. You provide links like <a ui-sref="">
. Note that even if you use <a href="">
in UI-Router, just like you would do in ng-router, it will still work.
所以,即使你决定改变您的网址有一天,你的状态
将保持不变,你只需要在的.config改变URL
。
So, even if you decide to change your URL some day, your state
will remain same and you need to change URL only at .config
.
虽然ngRouter可以用来进行简单的应用程序,用户界面,使得路由器开发复杂的应用程序变得更加容易。在这里,它的维基。
While ngRouter can be used to make simple apps, UI-Router makes development much easier for complex apps. Here its wiki.
这篇关于是什么在AngularJs $ routeProvider和$ stateProvider之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!