我有角的JS'路线'如下:
I have a 'route' in Angular JS as follows
$routeProvider.when('/foos/:fooId', { controller: FooController, templateUrl: 'foo.html'});
和它的伟大工程,除非:fooId组件包含一个/或%2F(EN codeD格式)
and it works great, unless the :fooId component contains either a '/' or '%2F' (encoded form)
我怎样才能使这项工作,我的'fooId可以包含/秒?
How can I make this work, my 'fooId' can contain /s ?
您不能很容易地做到这一点,因为如果你在使用它与%2F
A环节,浏览器将只去code为你,它会最终被 /
。 AngularJS目前不允许你在 $路线
PARAMS使用 /
。
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.
您可以双击连接code它,就像在这个plnkr:http://plnkr.co/edit/e04UMNQWkLRtoVOfD9b9?p=$p$pview
You can double encode it, like in this 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: '/'});
});
和链接将是:< A HREF =#/ DIR / A%252Fb%252Fc>点击此处< / A>
另一种选择,如果你有 /
在参数字符可以在这里找到了一组数字:How我可以让angular.js路线长路径
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 path