今天我尝试在我的应用程序中使用HTML5 pushstate删除# 从 网址。为了实现这一点,我在路由器中注入了$ locationProvider 并执行此$ locationProvider.html5Mode(true);正如我从中发现的那样 这么多在线资源。最初它没有工作,然后我删除 所有#from urls并添加到index.html。
Tts working fine for every url in whole application. In my application u can upload file and if file uploaded successfully, File name would be visible as a on the page and if u click on the file name you would be able to download it. MY PROBLEM is now in pushstate, if we click on file name nothing is happening. I tried multiple combination but no luck.
// Router.js
angular.module('myApp').config(function ($stateProvider, $urlRouterProvider,$locationProvider) {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'app/main/main.html',
controller: 'MainCtrl',
controllerAs: 'mainCtrl'
})
$urlRouterProvider.otherwise('/');
$locationProvider.html5Mode(true);
});
<!--here is the link which is not working-->
<!--{{documentUrl}} stands for /api/document/getExistingFile -->
<tr data-ng-repeat="fileModel in files">
<td>
<span ng-show="fileModel.status == '200'">
<a href="javascript:void(0)" ng-href="{{documentUrl}}/{{fileModel.id}}">{{fileModel.file.name}}</a>
</span>
<span ng-hide="fileModel.status == '200'">
<strong>{{ fileModel.file.name }}</strong>
</span>
</td>
<!--below code of index,html where i am defining <base href="/"> -->
<head>
<base href="/">
</head>