Reputation: 7693
From my angular application I need to remove # value from URL.As an example I need to execute this url with parameter name cal name
and then it's shown in html page.
Example:
THIS URL:
http://localhost/angular_ex/url.html#?name=test
IN TO :
http://localhost/angular_ex/url.html?name=test
Because from C# WebRequest class didn't allow to send web request along with the hash value.
I try to use this stack overflow post also.
Html code:
<!DOCTYPE html>
<html ng-app="HelloApp">
<head>
<script src="./angular/angular.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="index.js"></script>
</head>
<body ng-controller="myCtrl">
<p>Url parameter value is :{{name}}</p>
</body>
</html>
index.js
var newApp = angular.module('HelloApp', []);
newApp.controller('myCtrl', newAppConstructor);
newAppConstructor.$inject = ['$scope', '$location'];
function newAppConstructor($scope, $location) {
$scope.name = $location.search().name;
}
Upvotes: 1
Views: 449
Reputation: 785
Try with this answer
newApp.config(function($locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
})
Upvotes: 3