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;
}
2
  • maybe this can help you stackoverflow.com/questions/16677528/… Commented Feb 28, 2017 at 5:01
  • 1
    where are your routes? have you added $locationProvider.html5Mode(true) Commented Feb 28, 2017 at 5:12

1 Answer 1

3

Try with this answer

newApp.config(function($locationProvider) {
    $locationProvider.html5Mode({
     enabled: true,
     requireBase: false
     });
  })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.