Routing issue with angularjs while version update

39 views Asked by At

Scenario : I have update my current angularjs version from AngularJS v1.5.5 to AngularJS v1.5.7. Application is working fine but there is issue with URL routing it is behaving different. Let's see acceptance criteria below.

Try 1

Original URL as below and this is the expected result also.

https://u-unalytix.milestoneinternet.com/Unalytix.Web.UAT/dashboard/marketing-channels

Just after update version I was getting error with commented lines which below.

$locationProvider.html5Mode(true);  
// $urlrouterprovider.rule(function ($injector, $location) {
       // var path = $location.path();
       // if (path != '/' && path.slice(-1) === '/') {
          // $location.replace().path(path.slice(0, -1));
       // }
// });

Result :

https://u-unalytix.milestoneinternet.com/U/dashboard/marketing-channels

You can see here due to some reason we are not getting the expected result.Then I try with another code of piece in module.config. After googling I got some answer to resolve this issue and I tried as follow but still could not got expected result.

Try 2

I tried with this piece of code still could not got expected result.

$locationProvider.html5Mode({
    enabled: false,
    requireBase: true
});

Result :

This time getting /# in URL.

https://u-unalytix.milestoneinternet.com/Unalytix.Web.UAT/#/dashboard/marketing-channels

Don't know the issue. If anyone have idea about this issue then please share with me.

1

There are 1 answers

1
chandanchaudhary On

To achieve this you need to make two changes.

  1. Add this inside your config.
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('');
  1. Add base of your application in your index.html head tag
<head>
...

  <base href='/' />

...
</head>