我有一些像这样的HTML(我甚至懒得发布JS,因为它是一个过于复杂的混乱):
<html>
<body>
<div class="container">
<h3 class="text-center">Administration</h3>
</div>
<div class="form-inline text-center">
<div class="form-group">
<label>Managing Business</label>
<select ng-options="business.name for business in businesses" ng-model="managingBusiness" class="form-control restaurant-select"></select>
<label>Program</label>
<select ng-options="program.description for program in selectablePrograms" ng-model="managingProgram" class="form-control restaurant-select"></select>
</div>
</div>
<hr/>
<div class="col-md-2">
<ul class="nav nav-pills nav-stacked">
<li ng-class="{ active: isActive('/admin/overview')}"><a href="#/admin/overview">Overview</a></li>
<li ng-class="{ active: isActive('/admin/generators')}"><a href="#/admin/generators">Generators</a></li>
</ul>
</div>
<div class="col-md-10">
<div ng-include="'views/partials/admin/overview.html'" ng-show="isActive('/admin/overview')"></div>
<div ng-include="'views/partials/admin/generators.html'" ng-show="isActive('/admin/generators')"></div>
</div>
</body>
</html>
唯一重要的是这个:
$scope.isActive = function (viewLocation) {
return viewLocation === $location.path();
};
问题是当用户选择要更改的选项卡(概述/生成器)时,重新加载整个页面。这很糟糕,因为我试图将所选业务的状态保持在最顶层。
我做错了什么?为什么在没有运行重载命令的情况下重新加载页面?