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?
Can we use ngRoute and ui.router together in angularJS app.js?
Asked Answered
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
Yes you can use both.
var myModule = angular.module("myModule", ["ui.router", "ngRoute"]);
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
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
© 2022 - 2024 — McMap. All rights reserved.