Tôi đang sử dụng Bộ định tuyến giao diện người dùng góc. Vui lòng tìm mã bên dưới.Không thể tải ui-view ngay cả khi trạng thái thay đổi
index.html
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.3/angular-ui-router.min.js"></script>
<script src="../../Scripts/AngularControllers/LoginHomeControllers/RouteMainController.js"></script>
<script src="../../Scripts/AngularControllers/LoginHomeControllers/LoginController.js"></script>
</head>
<body>
<div ui-view="mainview"></div>
</body>
</html>
RouteMainController.js
var app = angular.module("appHome", ['ui.router']);
app.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/login');
$stateProvider
.state('introduction', {
url: '/',
views: {
'mainview':
{
templateUrl: 'Login.html',
controller: 'ctrlLogin'
}
}
})
.state('login', {
url: '/login',
views: {
'mainview':
{
templateUrl: 'Login.html',
controller: 'ctrlLogin'
}
}
})
.state('home', {
url: '/home',
views: {
'mainview':
{
templateUrl: 'Home.html',
}
}
})
.state('home.requestsummary', {
url: '/requestsummary',
views: {
'homedetailview':
{
templateUrl: 'Test1.html',
}
}
})
.state('home.requestsummary.requestdetail', {
url: '/requestdetail',
views: {
'homedetailview':
{
template: "'<h3>Foo</h3>'"
}
}
})
});
login.html
<div>
<button id="btnAdd" type="submit" ng-click="Login()">Login</button>
</div>
LoginController.js
var myApp = angular.module('appHome');
myApp.controller("ctrlLogin", ['$scope', '$location', function ($scope, $location) {
$scope.Login = function() {
window.location.href = '#!home/requestsummary';
}
}]);
home.html
<!--Sample Code for displaying Menu Tab and corresponding link-->
<li>
<a href="#">Employees <span class="caret"></span></a>
<ul class="dropdown-menu sub-menu">
<li><a ui-sref=".employeeadd">Add Employee Record</a></li>
</ul>
</li>
<div ui-view="homedetailview"></div>
Test1.html
<a ui-sref=".requestdetail">Hello World</a>
Tôi có thể đăng nhập thành công và nhận được tab menu với "Hello Liên kết thế giới. Tôi muốn hiển thị Menu Tab luôn luôn và thay đổi văn bản bên dưới động.
Vấn đề của tôi là bất cứ khi nào tôi nhấp vào liên kết "Hello World", tôi mong đợi Foo xuất hiện thay cho liên kết "Hello World" nhưng nó không hoạt động. Thậm chí nó đang thay đổi trạng thái (url) nhưng nó không tải chế độ xem thực tế.
Hãy giúp tôi về điều này.
Có vẻ như bạn muốn 'requestdetail' là anh chị em của' requestummary' thay vì trạng thái con cháu – shaunhusain
Có thể có nhiều liên kết như "Hello World" trong trang requestummary và nó sẽ mở trang requestdetail dựa trên liên kết được nhấp. Nhưng bất cứ khi nào liên kết được nhấp thì nội dung requestdetail sẽ ghi đè nội dung requestummary. đường ra là gì? – user1843970