Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS "#!" on url

someone knows what "#!" Means. on the url?

I was working until then this appears,I had a "#" always in the url and would like to keep it that way. Currently routing is not working anymore,probably because of this url change.

It's part of a business project, i don`t want to change to html5Mode.

I tried to use:

$locationProvider.hashPrefix("");

Even correcting the url in this way routing is having problems

like image 559
A. Pozzi Avatar asked Dec 12 '16 23:12

A. Pozzi


People also ask

What AngularJS used for?

AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. AngularJS's data binding and dependency injection eliminate much of the code you would otherwise have to write.

Is AngularJS better than Nodejs?

Node. js is more preferable when faster and scalable web development is needed. It is usually used for building small-sized projects. Angular is preferred when real-time applications, for example, chat apps, or instant messaging are needed.

Is AngularJS vs Angular?

What is the difference between Angular vs AngularJS? One vital distinction between Angular vs AngularJS is AngularJS is JavaScript-based while Angular is TypeScript based. These two frameworks have similarities as a front end, open-source platform that create dynamic SPAs but let's look at their differences.

Is AngularJS same as HTML?

AngularJS Introduction. AngularJS is a JavaScript framework. It can be added to an HTML page with a <script> tag. AngularJS extends HTML attributes with Directives, and binds data to HTML with Expressions.


Video Answer


2 Answers

You can use html5Mode in your location provider.

$locationProvider.html5Mode(true);

more info https://scotch.io/tutorials/pretty-urls-in-angularjs-removing-the-hashtag

like image 74
Danilo Velasquez Avatar answered Oct 12 '22 20:10

Danilo Velasquez


Thats called hash-bang.

To fix this use :

    angular.module('yourApp', [])
    .config(['$locationProvider', function($locationProvider) {
        $locationProvider.hashPrefix('');
    }]);

Adding html5Mode would even get rid of the '#' in the url but if you refresh the page, then you would get a 404 error. This can be fixed by configuring your server a bit. For that you might want to check the nice little tutorials :

  1. https://scotch.io/tutorials/pretty-urls-in-angularjs-removing-the-hashtag
  2. https://www.theodo.fr/blog/2017/01/pretty-url-in-angularjs-and-loopback-drop-the/

There is another answer to the hashbang issue in stackoverlow :

Doing links like Twitter, Hash-Bang #! URL's

like image 34
onFuryRoad Avatar answered Oct 12 '22 22:10

onFuryRoad