0
我有得到引導導航欄+角路由的工作問題。我不明白髮生了什麼,因爲在另一個應用程序上的一個非常類似的代碼正在工作。角路由和引導導航欄
我有以下的HTML在我的index.html
<div ng-controller="CoreController as core">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">myApplication</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li ng-class="core.navHome"><a href="#home">Home <span class="sr-only">(current)</span></a></li>
<li ng-class="core.navStatistic"><a href="#statistic">Statistic</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<!-- angular templating -->
<!-- this is where content will be injected -->
<div ng-view></div>
</div>
我app.js:
$routeProvider.when('/', { templateUrl: 'templates/home.html', controller: 'MainController', controllerAs: 'main' });
$routeProvider.when('/statistic', { templateUrl: 'templates/statistic.html', controller: 'StatisticController', controllerAs: 'statistic' });
// Default route
$routeProvider.otherwise({ redirectTo: '/' });
當我打的統計鏈接,我的網址顯示: http://localhost/myApplication/#!/#statistic 和我看到家庭模板。然後
主頁按鈕顯示 「http://localhost/myApplication/#!/」
是排名!這是爲什麼?
嘗試刪除''#。像這樣的''myApplication –
不會改變任何東西。以防萬一,我也刪除了緩存。 – Stef