gpt4 book ai didi

javascript - AngularJS UI-路由器 : Rendering parent partial with child partial

转载 作者:行者123 更新时间:2023-11-29 19:46:43 26 4
gpt4 key购买 nike

我正在使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com