Can we use ngRoute and ui.router together in angularJS app.js?
Asked Answered
D

2

9

Previously, I was using ngRoute in my main controller. I have to create child view functionality and it is only achieved by UI-Router. please suggest?

Drudgery answered 29/12, 2014 at 15:46 Comment(2)
You can, as @Suneet suggests -- but you should probably just migrate your application to uiRouter instead of using both.Scutter
@Martin: Yes you are right.Fastness
F
2

Yes you can use both.

var myModule = angular.module("myModule", ["ui.router", "ngRoute"]);
Fastness answered 29/12, 2014 at 15:57 Comment(2)
Can you use both simultaneously like <body ng-view ui-view ></body> ?Blas
No, the two directives will compete for transclusion on the body. Depending on your styling, you could try putting one after the other (i.e., <body><div ng-view></div><div ui-view></div></body>).Skindeep
T
2

Yes, you can use ngRoute/angular-route ($routeProvider) and ui-router ($stateProvider) together (in particular, the second inside of the first). Check this repo's master to find the example. In a couple of words, the ui-router in this case will have the possibility to provide navigation and nested states/views inside of "ng-view-provided space". I have answered almost the same question with more details and pros/cons at Quora

Tientiena answered 3/2, 2018 at 5:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.