我有以下 html 页面,
- index.html - 有
ng-view
- 欢迎.html
- app.html - 有许多子页面。所以需要使用
ng-view
我最初的$routeProvider
是,
$routeProvider
.when('/', {
redirectTo: '/welcome'
})
.when('/welcome',{
templateUrl: 'views/welcome.html',
controller: welcomeCtrl
})
.when('/app',{
templateUrl: 'app.html',
controller: mainCtrl
})
.otherwise({
redirectTo: '/welcome',
});
现在 app.html
中有多个子页面。如何为此添加路由?
我对 AngularJS 比较陌生。我尝试在 app.html
中添加 ng-view
并尝试在同一个 $routeProvider
中定义路由,但是当我这样做时,我收到错误,超过最大调用堆栈
错误,并且我的浏览器内存像任何东西一样增加,然后挂起。我严重缺少一些基本的东西
提前感谢您的帮助。
最佳答案
我建议您使用angular ui-router :
AngularUI Router is a routing framework for AngularJS, which allows you to organize the parts of your interface into a state machine. Unlike the $route service in the Angular ngRoute module, which is organized around URL routes, UI-Router is organized around states, which may optionally have routes, as well as other behavior, attached.
关于javascript - AngularJS - $routeProvider 和 data-ng-view 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28499177/