I've a requirement where I need to remove the # from url of angularJS application because I need to integrate with google drive api and it is not accepting the url's with #.
So, I've gone thorugh some suggestions on web here and have done some changes and removed the hash. but I'm unable to load the page after refresh.
previous url : http://localhost:54867/index.html#/Home/Chat current url : http://localhost:54867/Home/Chat
as, there is no index page defined in the new url, we're unable to load the page after refresh.
Actually I've a login page and after login I'm redirecting to the index page using
window.location.href = '../index.html';
My app.js Code
var plusapp = angular.module('plusapp', [
'ngRoute',
'ngAnimate',
'ngSanitize',
'ui.bootstrap',
'checklist-model',
'dx'
]).
config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider.
when('/Account/Login', {
templateUrl: '/Account/Login',
controller: 'LoginController'
}).
when('/Home/Chat', {
templateUrl: '/Home/Chat',
controller: 'ChatController'
}).
otherwise({
redirectTo: '/Home/Chat'
});
$locationProvider.html5Mode(true);
}
]);
and in my index page I've also place base tag this way
<head>
<meta charset="utf-8">
<base href="/">
My final requirement is to remove the hash and load the page even after refresh.
BTW, I'm using MVC and angularJS
Can someone, please help me through this?
Do anyone got a link to a sample using mvc and angular to remove hash, where I can check and follow the steps?
$locationProvider.html5Mode(true);to remove the hash also refer stackoverflow.com/questions/37559271/…