What means #! mean in ui.router?

I am using Angular ui.router to navigate my application. Typically, the URL should look like this:

http://localhost:8001/#/start 

But in my case it looks like this:

 http://localhost:8001/#!/start 

What does it mean?

I also admitted that if I call a URL from this site that is different from my start page, I always redirect as the URL seems to be invalid.

 mainApp.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) { 'use strict'; $urlRouterProvider.otherwise('start'); $stateProvider .state('start', { url: '/start', templateUrl: 'views/start.html' }) .state('registration-activate', { url: '/registration/activate/{activationKey}', templateUrl: 'views/registration-activation.html' }) ; }]); 

Whenever I try to call localhost: 8001 / # / registration / activate / xyz, I get redirected to the start page.

+5
source share
2 answers

Ok guys, thanks for your explanation. I decided that I could not call the URL from the link, just adding this to my configuration:

 $locationProvider.hashPrefix(''); 
+2
source

If the browser is an HTML5 browser, angularJS will redirect it to #!

Otherwise, it will be only # .

Read this here at $location to learn more about why this is happening.

  • Open regular url in legacy browser -> redirect to hashbang url
  • Opening hashbang url in modern browser -> rewrite regular url
0
source

Source: https://habr.com/ru/post/1261858/


All Articles