I have a 'route' in Angular JS as follows
$routeProvider.when('/foos/:fooId', { controller: FooController, templateUrl: 'foo.html'});
and it works great, unless the :fooId component contains either a '/' or '%2F' (encoded form)
How can I make this work, my 'fooId' can contain /s ?
Based on the answer of Langdon, I created a filter which encodes everything twice, and another one which decodes:
I use this in my product links as follows:
On the product page, I decode the product name:
You need not to encode anything here. Just add * in your path Param as mentioned below and enable html5Mode
You can't easily do this because if you use a link with
%2F
in it, the browser will just decode it for you and it'll end up being/
. AngularJS currently doesn't allow you to use/
in$route
params.You can double encode it, like in this plnkr: http://plnkr.co/edit/e04UMNQWkLRtoVOfD9b9?p=preview
And the link would be:
<a href="#/dir/a%252Fb%252Fc">click here</a>
.Another option, if you have a set number of
/
characters in your parameters can be found here: How can I make the angular.js route the long pathinclude $locationProvider.hashPrefix(''); in your config.