8

I am using angular-ui-router with my angular 1.3 app. I am looking to upgrade it to angular 1.5. What are the best options for routing in angular 1.5? Shall I continue with angular-ui-router or shall I move to something like angular-new-router. Please suggest. Also, If there is a documentation for easy migration, it will be helpful.

4
  • Please do a little research before asking a question, There are only two angular routers only i.e ng-route (old one) and ui-router (which is already you implemented in your current app). There are no new routers. Commented Mar 29, 2016 at 12:47
  • Why should there be any trouble upgrading to Angular 1.5? Are there any certain breaking changes that you have noticed that you are afraid might break your project? No matter what, there should be no particular reason for you to switch out your router since you are already using the de-facto standard for Angular routing. Commented Mar 29, 2016 at 13:28
  • Why need migration in ui-router , i know that there have no major change recently in ui-router, so hope it have not any issue and good news that Angular team partially contribute to ui-router. Commented Mar 29, 2016 at 15:21
  • 1
    Thanks guys. @mJunaidSalaat, I tried to look for resources related to it, but could not get any. That's why, asked this. Commented Mar 29, 2016 at 17:27

2 Answers 2

3

Routers in angular

As mentioned earlier, the two mainstream routers for angular.js is ngRoute an ui-router. There is the new router which is part of angular 2.0 - Although it promises amazing features, I currently do not recommend adoption of it and angular 2.0 until it's stable and because of stories like this and issues like this.

Read before upgrading

"Upgrading" to the newest stable release of any library is most alwasy preferable. But before you do; you should read the release notes for every single version up to the version that you're upgrading.

Check the migration guide

Google is working on improving their angular documentation. The migration documentation however is particularly good. Take a look at it here

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

Comments

3

Depending on the status of your project you might want to stick with the ui-router as angular 1.5 is backwards compatible with all your modules and the upgrade should be smooth (read the docs though, including the upgrade to 1.4).

On the other hand, Angular 1.5 is meant to bring us close to the concepts and architecture of Angular 2 and web components (which are now thought of as the future of web development) so it's a step on the learning curve that most ng1.x developers should take.

Angular 1.5 allows you to write your app in a component based fashion with a different routing mechanism, having routes/URLs load components that you defined instead of loading partials.

Routes can now be embedded in child components (say you have a Users module which has a /list, /details/:id/:slug, /edit/:id routes/sub-components and this Users module can be attached to whatever URL from your app: /users, /admin/users/ while keeping its internal routing mechanism. Your base app will have non-terminal routes for this kind of components (specified with /... meaning it will leave the consequent routing to the component itself).

Also, you can have multiple active routes at once (i.e. think modals, as in Gmail where you can look at a message and have the Compose popup and then navigate to the message list while still having the Compose popup open).

Routing events are now hooks that you can implement in your own component so you can do your resolves locally (fetch data, check for user rights, etc), taking care of destroying stuff, specify whether the component should be reused or reinstantiated, etc.

Bottom Line

In Angular 1.5 the new routing mechanism is based on components instead of states/views so your app needs a refactor towards this concept in order to fully benefit from it.

1 Comment

Thank-you all for all the good suggestions. especially @bosch Let me give the background,what I am looking for. My upgrade to Angular 1.5 is primarily driven by the need for custom domain support. For which I have added up another question as well. stackoverflow.com/questions/36085246/… For this intended purpose, looks like I need to refactor for component level routing. 1 question I have is what impact can it have on my existing controllers?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.