路径参数(里面没有编码的斜杠)
默认情况下,ui-router 对参数中的斜杠/
进行编码。如果要在 URL 中发送路径,则需要定义自定义参数类型。
限定:
module.config(['$urlMatcherFactoryProvider', function($urlMatcherFactory) {
$urlMatcherFactory.type('path', {
decode: function(val) { return val != null ? val.toString() : val; },
encode: function(val) { return val != null ? val.toString() : val; },
is: function(val) { return this.pattern.test(val); },
pattern: /[^/]+\/[^/]+/
})
}]);
并使用:
$stateProvider.state({
url: '/my-route/{directory:path}'
template: '<my-page></my-page>'
});
相关问题 。