1

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;
}
Community
  • 1
  • 1
Elshan
  • 7,339
  • 4
  • 71
  • 106
  • maybe this can help you http://stackoverflow.com/questions/16677528/location-switching-between-html5-and-hashbang-mode-link-rewriting – Hosar Feb 28 '17 at 05:01
  • 1
    where are your routes? have you added `$locationProvider.html5Mode(true)` – Sravan Feb 28 '17 at 05:12

1 Answers1

3

Try with this answer

newApp.config(function($locationProvider) {
    $locationProvider.html5Mode({
     enabled: true,
     requireBase: false
     });
  })
Elshan
  • 7,339
  • 4
  • 71
  • 106
Sujithrao
  • 789
  • 3
  • 12
  • 27