我正在使用UI-Router AngularJS 框架,用于渲染嵌套部分。我在渲染父部分及其子部分时遇到问题。这是我的代码:
window.app.config(['$stateProvider', '$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('class', {
url: '/classes/:classId',
templateUrl: '/views/class.html',
controller: 'ClassCtrl',
})
.state('class.questionList', {
url: '',
templateUrl: '/views/questionList.html',
})
}]);
在子状态的声明中,我将 url 设置为空字符串,以便它能够与其父状态同时呈现。但是,这不起作用,只有父 View 正在渲染。
最佳答案
给父状态添加属性“abstract: true”,通知UI-Router该状态只能通过子状态的激活来激活。这将使 URL/classes/:classId 激活这两种状态。
关于javascript - AngularJS UI 路由器 : Rendering parent partial with child partial,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18976716/