Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inject component router in Angular 1.5?

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

However, when I update to 1.5, I don't see a way to inject '$router' into my configuration.

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

But isn't the new router supposed to be included in 1.5?

Sorry, there doesn't appear to be much documentation on this. There's only the outdated docs that refer to Angular 1.4 and the Angular 2.0 docs.

When I try using the angular_1_router.js file, I get an $injector:modulerr when trying to use 'ngComponentRouter', so I haven't been able to go that route as a workaround.

like image 974
James Gentes Avatar asked Oct 30 '22 10:10

James Gentes


1 Answers

The new router is in a separate JavaScript file. You have to load it in your index.html file. I am not entirely certain if the 2.0 router works as is with 1.5 or not, but I believe that is supposed to be the case.

It's available here:

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

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

I am currently weighing migrating from ui-router to the new router but finding scant information available. This article looks to be somewhat helpful: http://geekswithblogs.net/shaunxu/archive/2015/03/30/horror-migrating-angular-ui-router-to-angular-new-router.aspx, but it's quite dated.

like image 101
Mike Feltman Avatar answered Nov 15 '22 07:11

Mike Feltman