AngularJS: ngRoute Not Working

It’s properly because you are using angular 1.6 and there has been a change the default hash-prefix:

Due to aa077e8, the default hash-prefix used for $location hash-bang
URLs has changed from the empty string (”) to the bang (‘!’). If your
application does not use HTML5 mode or is being run on browsers that
do not support HTML5 mode, and you have not specified your own
hash-prefix then client side URLs will now contain a ! prefix. For
example, rather than mydomain.com/#/a/b/c the URL will become
mydomain.com/#!/a/b/c.

If you actually want to have no hash-prefix, then you can restore the
previous behavior by adding a configuration block to you application:

appModule.config([‘$locationProvider’, function($locationProvider) {
$locationProvider.hashPrefix(”); }]); Source

So you have some options:

1. Set HTML5mode true

$locationProvider.html5Mode(true);

and in html set base in html header:

<base href="https://stackoverflow.com/">

Lastly change <a ng-href="#voip"> to

<a ng-href="https://stackoverflow.com/questions/41655534/voip">

2. Use the 1.6 way
Change
<a ng-href="#voip">

to
<a ng-href="#!voip">

3. Go back to old behaviour from 1.5 – set hash prefix manually

app.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('');
}]);

Leave a Comment