研究和应用这些技术是一项繁重的工作,但我无法解决这个问题。我的应用程序具有三个顶级导航,分别是家庭、体育和国家。
<head>
<script src="js/angular-ui-router.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/index.js"></script>
</head>
导航如下所示:
HTML 如下所示,位于 index.html 中
<ul>
<li><a ui-sref="home">Home</a></li>
<li><a ui-sref="sports">Sports</a></li>
<li><a ui-sref="country">Country</a></li>
</ul>
<div ui-view></div>
在sports.html 中,还有其他三个导航不起作用(它们甚至不可点击)。
<ul>
<li><a ui-sref="sports.football">Football</a></li>
<li><a ui-sref="sports.weightlifting">Weightlifting</a></li>
<li><a ui-sref="sports.swimming">Swimming</a></li>
</ul>
<div ui-view></div>
角度看起来像
$stateProvider
.state('home', {
url: '/',
templateUrl: 'index.html'
})
.state('sports', {
url: '/sports',
templateUrl: 'sports.html'
})
.state('country', {
url: '/country',
templateUrl: 'country.html'
})
.state('sports.football', {
url: '/football',
templateUrl: 'sports/football.html'
})
.state('sports.weightlifting', {
url: '/weightlifting',
templateUrl: 'sports/weightlifting.html'
})
.state('sports.swimming', {
url: '/swimming',
templateUrl: 'sports/swimming.html'
});
基本上,当用户打开应用程序时,顶部应该有 Home、Sports 和 Country 的菜单栏。当用户点击“运动”时,该页面中应该会显示另一个视图/另一个子导航,显示足球、举重和游泳。但是,这些子导航不可点击且无法正常工作。
如果您能帮助我找出问题所在,将不胜感激。