Can we use ngRoute and ui.router together in angul

2019-06-16 09:00发布

问题:

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?

回答1:

Yes you can use both.

var myModule = angular.module("myModule", ["ui.router", "ngRoute"]);


回答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