In our Angular application, we have to deal with an identifier containing a period. For example:
book = { id: '123.456' }
We have problems using an identifier such as URL parameters. Everything works well if navigation occurs through "Angular", namely clicking on the link that calls $state.go('bookDetails', {bookId: book.id}); . But when reloading the page, everything does not work.
"Cannot GET / bookDetails? BookId = 123.456"
in the controller:
$scope.viewBookDetails = function() { $state.go('bookDetails', {bookId: book.id}); }
in view
<a href="" ng-click="viewBookDetails(); $event.stopPropagation();">
in the router:
.state('bookDetails', { url: '/bookDetails?bookId' }
in browser:
https:
The link works if the "dot" is replaced with %2E in the browser.
We tried to replace "dot" with "% 2E" in the parameter for $ state.go ()
$scope.viewBookDetails = function() { $state.go('bookDetails', {bookId: book.id.split('.').join('%2E')}); }
but it doesnβt work, because "%" is automatically encoded, and the "dot" in the browser is replaced with "% 252E"
https://example.com/bookDetails?bookId=123%252E456
angularjs urlencode angular-ui-router query-parameters
klode
source share