Wednesday, February 7, 2018

javascript - Angular UI Router VS ngRoute - mini-test



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:





  1. Angular UI Router allows you to save state when switching tabs, ngRoute does not

  2. They both use URLs to uniquely identify views

  3. They both associate a template and a controller with a view

  4. They both use the same service for route parameters



My answers:





  1. True

  2. True

  3. False

  4. True



My justifications:




  1. Following from the question " What is the difference between angular-route and angular-ui-router? " I am fairly sure that option 1 is true.


  2. 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.

  3. 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.

  4. Given that Angular UI is an extension of ngRoute, I believe that 4 is also true.


Answer



After some sound advice, I finally got it! Here are my answers and justifications.



Answers:





  1. True

  2. True

  3. True

  4. False



Justifications:




  1. 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).


  2. Even though Angular UI can have nested views, those views can still be accessible by specific and unique URLs.

  3. Even though a template can have several views, nothing prevents the relation of 1-1-1 with a controller-template-view. It is possible.

  4. 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 !


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...