Angularjs : $locationProvider.hashPrefix("!") ;

20,867

If you want a ! in the URL before the fragment identifier begins, then you need to put it in the URL to start with and not try to do it with Angular.

http://www.example.com/#foo and http://www.example.com/#!foo are different parts of the same page.

But http://www.example.com/#foo and http://www.example.com/!#foo are different pages altogether.

Share:
20,867
user2534381
Author by

user2534381

Updated on July 09, 2022

Comments

  • user2534381
    user2534381 almost 2 years

    I want to show url as "www.test.com/!#" for that i am using $locationProvider.hashPrefix("!") ; but it shows url as "www.test.com/#!" . i want "!" before hash not after hash.

    Thanks

    var app = angular.module('app', []);
    app.config(function ($routeProvider, $locationProvider) {
        $locationProvider.html5Mode(false);
        $locationProvider.hashPrefix("!");
        $routeProvider.when('/', {
            templateUrl: "app.html",
            controller: "AppCtrl"
        }
    
        )
            .when('/Program', {
            templateUrl: "detail1.html",
            controller: "Redirect"
        })
            .when('/Program/123456/channel/78458585',
    
        {
            templateUrl: "details.html",
            controller: "Detail"
        });
    });
    
    
    
    app.controller("AppCtrl", function ($scope) {
    
    });
    
    app.controller("Detail", function ($scope, $location) {
    
    });
    
    app.controller("Redirect", function ($scope, $location) {
        $location.path("/Program/123456/channel/78458585")
    });
    
  • user2534381
    user2534381 over 10 years
    it there any waty to do it with angularjs.. $locationProvider.hashPrefix("!") by the name should supposed to append it before hash.why it is appearing after hash.