0

I am creating an AngularJs application and everything is working fine.

Yet, I am facing an issue trying to remove #!/ from my url

When I run http-server in console it throws

Available on: http://127.0.0.1:8080

Then I enter there and the url automatically changes to http://127.0.0.1:8080/#!/

I have this in my route provider

    .when('/', {
        templateUrl: 'galleryMap.html',
        controller: 'GalleryMapController'
    })

    .when('/photo/:id', {
        templateUrl: "detail.html",
        controller: 'DetailPageController'
    })

The I call the url this way

$window.location.href = /photo/3;
$window.location.href = /;

Both don't work unless their urls are written like this http://127.0.0.1:8080/#!/photo/3 http://127.0.0.1:8080/#!/

Is it possible to make it work like a normal url like this http://127.0.0.1:8080/photo/3 without that horrible tags?

2
  • what router are you using? Commented Feb 1, 2018 at 20:42
  • @DanielA.White galleryMapApp.config(function ( $routeProvider) { $routeProvider .when('/', { templateUrl: 'galleryMap.html', controller: 'GalleryMapController' }) .otherwise({ redirectTo: '/' }); }); Commented Feb 1, 2018 at 20:44

1 Answer 1

0

The "horrible tags" are used to indicate routing on the client-side, rather than the server-side. Loading on the client-side allows the page to not need to completely reload in order to load a new page.

However, you can still perform client-side routing without the hash. You should be able to add this to your application's config to remove the hash:

$locationProvider.html5mode(true);
Sign up to request clarification or add additional context in comments.

2 Comments

This doesn't work. Im getting blank pague when I try 127.0.0.1:8080/photo/4
Are you sure you placed it correctly? Try reading scotch.io/tutorials/… and see if it helps. If not, I'll create an example.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.