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

为君一笑 提交于 2020-01-14 07:24:29

问题


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



来源:https://stackoverflow.com/questions/27691897/can-we-use-ngroute-and-ui-router-together-in-angularjs-app-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!