【发布时间】:2018-03-22 15:41:19
【问题描述】:
这是我的 JS(我将 html5Mode 设置为 True,我正在使用 $http $window 和 $location:
.config(['$locationProvider', function($locationProvider){
$locationProvider.html5Mode(true); // Important. Needed for URLs.
}])
.controller("MainCtrl", ["$http", "$window", "$location", function($http, $window, $location) {
基础标签也设置好了,像这样:
<base href="/">
这是我的html页面:
<div>
<ul class="nav nav-pills">
<li><a href="/">Home ▼</a></li>
<li><a href='/post'>Post</a></li>
<li><a href="/settings">Settings</a></li>
<li><a href ng-click="ctrl.logoutUser()">Logout</a></li>
</ul>
</div>
问题是,当我单击任何链接时,URL 会更新,但页面不会刷新。如果我从控制器中删除 $location 则它可以正常工作,但我需要 $location 从我的 JS 中获取 URL 以用于其他目的。有没有办法阻止 AngularJS 阻止刷新网页?
【问题讨论】:
标签: angularjs