%2F
is the percent-encoding for the forward-slash /
character.
This problem is related to the fact that AngularJS 1.6 has changed the default for hash-bang urls in the $location
service.
To revert to the previous behavior:
appModule.config(['$locationProvider', function($locationProvider) {
$locationProvider.hashPrefix('');
}]);
For more information, see SO: angularjs 1.6.0 (latest now) routes not working.
The most simple solution is to add a !
to client-side URLs (if not using HTML5 mode, which you probably do if you're here).
Client-side, update URLS like this:
#/foo/bar
> #!/foo/bar
And since you keep the #
, there is no issue of conflict with server-side routing. Everyone happy.
A bit late to the party but adding a '!' to your URLs will work just fine. This bothered me for a bit as well. This is a change in the latest AngularJS 1.6.x and I read somewhere that Google requires SPAs to have that '!' after the hash. As a result my routes look as they should but my navigation makes sure I add '!' in my references. For example:
<ul>
<li><a href="#!/">Home</a></li>
<li><a href="#!/page2">Page 2</a></li>
<li><a href="#!/page3">Page 3</a></li>
<li><a href="#!/page4">Page 4</a></li>
</ul>
I hope this helps you.
Regards!
For me, i fixed the problem :
app.config(function($locationProvider) {
$locationProvider.hashPrefix('');
$locationProvider.html5Mode({
enabled: false,
requireBase: true
});
});
<a href="#/mylink/"> <span>MyLink</span></a>
Which give : http://blablabla.co:8888/blabla#/mylink/
Hope this help.
slash encoding can be disabled:
$urlMatcherFactoryProvider.type('SlashFix', {
raw: true,
});
$stateProvider
.state('content',{
url: '/{slug:SlashFix}'
...
})
as described here https://www.coditty.com/code/angular-ui-router-replacing-slash-with-2f-quick-fix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With