In a mini test that I made there were 4 (true/false) questions about UI Router VS ngRoute. I did the test and my research, but I am not sure about my answers. Can someone please confirm and help me justify?
The questions:
Angular UI Router allows you to save state when switching tabs, ngRoute does not They both use URLs to uniquely identify views They both associate a template and a controller with a view They both use the same service for route parameters My answers:
True True False True My justifications :
Following from the question " What is the difference between angular-route and angular-ui-router? " I am fairly sure that option 1 is true. Now this one I am not sure. I know that you can use UI Route to create dynamic URLs, but that is as far as my knowledge goes. This one I believe is false. In an Angular UI template one can have several views, in fact a common example is with pages that have a top section, a middle section and a common bottom section. If this implication however means that the affirmation is incorrect, I am not sure, but I am led to believe it. Given that Angular UI is an extension of ngRoute, I believe that 4 is also true.
After some sound advice, I finally got it! Here are my answers and justifications.
Answers:
True True True False Justifications:
Following from the question " AngularJS : Difference between angular-route and angular-ui-router " one can see that states can be used to keep a history stack. (Keep states in mind, it will be useful later on). Even though Angular UI can have nested views, those views can still be accessible by specific and unique URLs. Even though a template can have several views, nothing prevents the relation of 1-1-1 with a controller-template-view. It is possible. And here, states come in handy. Angular UI uses a state service, while ngRoute does not. The focus of the question was on this, but I was not getting it. There you go, hope it helps other people !
链接地址:
http://www.djcxy.com/p/77972.html
上一篇:
AngularJS:通过UI路由器加载js文件
下一篇:
Angular UI路由器VS ngRoute