我可以对URL隐藏$location.path和$location.search密钥吗?
现在网址是:url.com/page.html?key=value我需要网址如下:url.com/value...
发布于 2017-01-23 22:24:16
我还没有测试它,但我想这会解决你的问题。
app.run(['$rootScope', '$location', function ($rootScope, $location) {
$rootScope.$on("$routeChangeStart", function (event, next, current) {
if (next && next.$$route) {
var params = next.params;
var hasQuery = Object.keys(params).length!==0;
if (hasQuery) {
event.preventDefault();
$rootScope.$evalAsync(function() {
$rootScope.routeParams = params;
$location.path(next.$$route.originalPath);
});
}
}
});
}]);您可以在每个控制器中通过$rootScope.routeParams访问routeParams。
https://stackoverflow.com/questions/41807434
复制相似问题