我正在使用AngularJS构建一个网站,并使用angular-route库来查看网站的不同页面。我的网站工作正常,但当我移动到不同视图时,URL中会有一个哈希标签。为了删除哈希标签,我正在使用
但是在页面刷新时,这并不起作用。我的代码如下:- Index.html
$locationProvider.html5Mode(true);
但是在页面刷新时,这并不起作用。我的代码如下:- Index.html
<body data-ng-app="myapp" data-ng-controller="myctrl">
<div data-ng-include=" 'pages/menu.html'"></div>
<div ng-view class="view-animate"></div>
<div data-ng-include=" 'pages/footer.php' "></div>
<body>
app.js
'use-strict'
var tc = angular.module('myapp', ['ngRoute']);
tc.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/home', {
templateUrl: 'pages/home.html',
})
.when('/about', {
templateUrl: 'pages/about.html',
})
.otherwise({
redirectTo: '/home'
})
}]);