gpt4 book ai didi

javascript - 父 View 不会被替换

转载 作者:行者123 更新时间:2023-12-03 06:39:16 26 4
gpt4 key购买 nike

我正在使用 AngularJs,目前 ui-router 遇到问题。状态“home.logged.board.patentDashboard”中的 View “patentBoard”不会替换父状态中的 View 。我不知道为什么要这样做,我在控制台上没有错误,并且所有 templateUrl 都是正确的。我还尝试将 View 名称“PatientBoard”替换为“PatentBoard@”,但没有什么...我将感谢任何人可以给我的所有帮助。

谢谢

index.html

<!DOCTYPE html>
<html lang="en" ng-app="neat">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NEAT</title>
<base href="/">
<link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../css/style.css">
<script src="webjars/jquery/1.12.4/jquery.min.js"></script>
<script src="webjars/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="webjars/angularjs/1.5.7/angular.min.js"></script>
<script src="webjars/angular-ui-router/0.2.18/angular-ui-router.min.js"></script>
<script src="../js/utils/utils.js"></script>
<script src="../js/neat.js"></script>
</head>
<body ng-controller="LanguageController">
<div ng-controller="AuthenticationController">
<header>
<div ui-view="navigationBar"></div>
</header>
<div ui-view></div>
</div>
</body>
</html>

board.html

<div class="container-fluid board">
<div class="row">
<div ui-view="patientBoard" class="col-sm-8"></div>
<div ui-view="messageBoard" class="col-sm-4"></div>
</div>
</div>

整洁的.js

angular.module('neat', ['ui.router', 'ngStomp', 'pascalprecht.translate'])
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/',
views: {
'': {
templateUrl: '/views/login/login.html'
},
'navigationBar': {
templateUrl: '/views/navbar/navigationBar.html'
}
}
})
.state('home.logged', {
abstract: 'true',
views: {
'@': {
templateUrl: '/views/board/board.html'
}
}
})
.state('home.logged.board', {
resolve: {
homeHref: function(RequestService) {
return RequestService.getHome()
.then(function(response){
return response.data;
});
}
},
views: {
'patientBoard' : {
templateUrl: '/views/board/patient/patientTable.html',
controller: 'PatientTableController'
},
'messageBoard' : {
templateUrl: '/views/board/message/messageBoard.html',
controller: 'MessageBoardController'
}
}
})
.state('home.logged.board.patientDashboard', {
params: {
patientHref: null
},
resolve: {
patientInfo: function($stateParams, RequestService) {
return RequestService.get($stateParams.patientHref)
.then(function(response) {
return response.data;
})
}
},
views: {
'patientBoard' : {
templateUrl: '/views/board/patient/patientDashboard.html',
controller: 'PatientDashboardController'
}
}
})
.state('home.logged.board.patientDashboard.patientInfo', {
views: {
'': {
templateUrl: '/views/board/patient/dashboard/patientInfo.html'
}
},
controller: 'PatientInfoController'
})
.state('home.logged.board.patientDashboard.patientAnalysis', {
views: {
'': {
templateUrl: '/views/board/patient/dashboard/patientAnalysis.html'
}
},
controller: 'PatientAnalysisController'
})
.state('home.logged.board.patientDashboard.patientHistory', {
views: {
'': {
templateUrl: '/views/board/patient/dashboard/patientHistory.html'
}
},
controller: 'PatientHistoryController'
});

$urlRouterProvider.otherwise('/');

});

最佳答案

由于 home.logged.board.patentDashboard 是 home.logged.board 的子级,因此状态(patentDashboard)正在 home.logged.board 中搜索名为“patentBoard”的 ui View 。

使 PatientDashboard 成为 home.logged 的​​子级(例如 home.logged. PatientDashboard),并且应该可以正常工作。


.state('home.logged. PatientDashboard', {
参数:{
病人引用:空
},
解决: {
病人信息:函数($stateParams,RequestService){
返回RequestService.get($stateParams. PatientHref)
.then(函数(响应){
返回响应数据;
})
}
},
观点:{
'病人板':{
templateUrl: '/views/board/Patient/PatientDashboard.html',
Controller :“PatientDashboardController”
}
}
})

有关更多信息,请查看 ui-router 的文档:Nested states and views

关于javascript - 父 View 不会被替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38042452/

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