Reputation: 2727
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
Upvotes: 1
Views: 519
Reputation: 11499
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.
Upvotes: 3