How to add component router in Angular 1.5?

I am working with Angular 1.5 and am trying to switch from using ui-router in 1.4 to the new Component Router in 1.5.

However, when I upgrade to 1.5, I don’t see a way to enter "$ router" into my configuration.

I know I can download angular_1_router.js from this repository: https://github.com/brandonroberts/angularjs-component-router

But shouldn't the new router be included in 1.5?

Sorry, there seems to be not much documentation. There are outdated documents that relate to Angular 1.4 and Angular 2.0 docs .

When I try to use the angular_1_router.js file, I get $injector:modulerr when I try to use the 'ngComponentRouter', so I could not go this route as a workaround.

+5
source share
1 answer

The new router is in a separate JavaScript file. You must load it into your index.html file. I'm not quite sure if router 2.0 works with 1.5 or not, but I believe that should be the case.

It is available here:

Just loading the js file should be sufficient, no injection is required.

The latest developer guide is here: https://docs.angularjs.org/guide/component-router

I am currently weighing migration from ui-router to a new router, but I find scarce information. This article looks somewhat useful: http://geekswithblogs.net/shaunxu/archive/2015/03/30/horror-migrating-angular-ui-router-to-angular-new-router.aspx , but it's pretty outdated.

+2
source

Source: https://habr.com/ru/post/1241669/


All Articles