I tried everything in other posts regarding removing the fragment identifier (#). Everything works as it should with the # identifier, but it would be a nice improvement for my project.
- I configured the $locationProvider and set html5Mode to true
- Set the
<base href="app" />
in my index.html tryed also<base href="/" />
. I used<base href="/" />
- Without setting a base
requireBase: false
. - Wrapping
$locationProvider.html5Mode(true)
intoif(window.history && window.history.pushState)
to check browser support for the html5 history API as someone suggested - I wrote a rule in web.config as someone else suggested.
- I tried all I could find after I googled it.
I am getting this error:
angular.js:13708 Error: Failed to execute 'pushState' on 'History': A history state object with URL 'http://sales/?_ijt=d1r1ladp5ro1tvflefsdpnfvd4' cannot be created in a document with origin 'http://localhost:52471' and URL 'http://localhost:52471/BeerbayCRM/BeerbayCRM/app/index.html?_ijt=d1r1ladp5ro1tvflefsdpnfvd4'.
See the list of available environment variables Your help will be very much appreciated! Thank you.
Here is my code:
app.config(['$routeProvider', '$locationProvider', '$httpProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: "views/productsView.html"
})
.when("/products", {
templateUrl: "views/productsView.html"
})
.when("/sales", {
templateUrl: "views/salesView.html"
})
.when("/charts", {
templateUrl: "views/chartsView.html"
})
.otherwise({
templateUrl: "views/productsView.html"
});
if (window.history && window.history.pushState) {
$locationProvider.html5Mode({
enabled: true
});
}
}
])
.controller("routeCtrl", function($scope, $location) {
$scope.setRoute = function(route) {
$location.path(route);
}
});
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<!--.....all the dependencies are here.....-->
<base href="app" />
</head>
<body ng-controller="myAppCtrl">
<div class="navbar navbar-inverse">
<a class="navbar-brand" href="#">Beerbay</a>
</div>
<div ng-controller="routeCtrl" class="col-sm-1">
<a ng-click="setRoute('products')" class="btn btn-block btn-primary btn-lg">Products</a>
<a ng-click="setRoute('sales')" class="btn btn-block btn-primary btn-lg">Sales</a>
<a ng-click="setRoute('charts')" class="btn btn-block btn-primary btn-lg">Charts</a>
</div>
<ng-view/>
</body>
</html>
Update: It is partially working after I started the application in a node server separate than one WebStorm uses. After I hit refresh page I get just a short message on the page: "Cannot GET /...__partial view name* "