javascript - Angular JS 'route' doesn't match component with %2F (encoded '/') -


i have 'route' in angular js follows

$routeprovider.when('/foos/:fooid', { controller: foocontroller, templateurl: 'foo.html'}); 

and works great, unless :fooid component contains either '/' or '%2f' (encoded form)

how can make work, 'fooid' can contain /s ?

you can't because if use link %2f in it, browser decode , it'll end being /. angularjs doesn't allow use / in $route params.

you can double encode it, in plnkr: http://plnkr.co/edit/e04umnqwklrtovofd9b9?p=preview

var app = angular.module('app', []);  app.controller('homectrl', function ($scope, $route) { }); app.controller('dirctrl', function ($scope, $route) {   var p = $route.current.params;    $scope.path = decodeuricomponent(p.p1); });  app.config(function ($routeprovider) {     $routeprovider             .when('/', {templateurl: 'home.html', controller: 'homectrl'})         .when('/dir/:p1', {templateurl: 'dir.html', controller: 'dirctrl'})             .otherwise({redirectto: '/'});  }); 

and link be: <a href="#/dir/a%252fb%252fc">click here</a>.

another option, if have set number of / characters in parameters can found here: how can make angular.js route long path


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -