1

I'm trying to develop with a complete mean stack (mean.js). I'm learning so maybe this question is a basic one. I spent so many days reading about different routing types in my frontend (angularjs). I found differences between ng-route and ui-router, the last one is a 3rd party module and has some clear advantages. I read in internet that if I use "ui-sref" I get a generated html for my state and an "href" tag. I understand this, but I searched a lot and I didn't find anything about "ui-route" what is used for?

I installed the official article example provided in meanjs http://meanjs.org/ and I have this that I cant understand.

 <ul class="nav navbar-nav navbar-right" data-ng-hide="authentication.user"> <li ui-route="/signup" ng-class="{active: $uiRoute}"> <a href="/#!/signup">Sign Up</a> </li> <li class="divider-vertical"></li> <li ui-route="/signin" ng-class="{active: $uiRoute}"> <a href="/#!/signin">Sign In</a> </li> </ul> 

What is ui-route in combination with ng-class for? Is always necessary that

Thank you

0

1 Answer 1

3

Both are a subset of Angular-UI, which has libraries that provide functionality beyond core angular. Both generate hrefs.

ui-sref is part of ui-router, a routing plugin

ui-route is part of ui-utils, a toolkit with a bunch of extra methods. It also creates a boolean $uiRoute for each element that you can match against, making things like active tabs easier to code. See http://angular-ui.github.io/ui-utils/ for more documentation.

So if you're using ui-router and ui-utils in your project, you could use either approach. Otherwise you can pick and choose as needed.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for you answer. if ui-sref and ui-route generates href? why is explicitly declared in that example?
Because when you use ui-route it also gives a boolean $uiRoute that you can match against. Makes things like active tabs easier to code. I'll update my answer to include this, but check out the docs at angular-ui.github.io/ui-utils
Thank you so much now everything is clearer in my mind

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.