1

So this was a weird thing to find out. Recently, I was going through some angular docs and came across the - tutorial. In the example mentioned in 9th step, I got a bit skeptical on looking at the url.

As you can see, in the URL there's this ! mark right after #. What is this ! mark used for in URL?

I know the usage of # mark in a url, but wasn't sure about using ! mark in one. Google also wasn't much helpful in this case.

Playing with the url a bit, I came to know that -

Not a huge question, maybe, but I would like to know the meaning and usage of the ! mark.

HardikT
  • 735
  • 1
  • 8
  • 24
  • Read the [hash-bang part of this wikipedia article](https://en.wikipedia.org/wiki/Fragment_identifier#Proposals) and afterwards the part about Twitter in [this article](https://www.w3.org/blog/2011/05/hash-uris/). `#` is only allowed at the end for fragments. But if you follow it up with a `!`, it becomes something else that the browser and the website need to understand. – Malte Hartwig Jan 04 '18 at 12:40
  • Also read [Angular routes contain #! in the url instead of #](https://stackoverflow.com/questions/41334798/angular-routes-contain-in-the-url-instead-of) – Malte Hartwig Jan 04 '18 at 12:41

1 Answers1

1

This is known as the "hashbang". It was a popular, but now discredited, way of constructing URLs.

Everything after the # in a URL in not sent by the browser to the web server. After the page has loaded, JavaScript running on the page can request what appears after the #. The browser then sends that data to the server, and retrieves a new part of the page.

In your example, the browser loads the page /app/ - a script running on that page looks at !/phones... and uses that data to do something.

As you may suspect - it's a slow, fragile, and unwieldily way to run a website.

See

Terence Eden
  • 14,034
  • 3
  • 48
  • 89