gpt4 book ai didi

angularjs - 如何重定向$ routeProvider.otherwise()保持给定的查询参数

转载 作者:行者123 更新时间:2023-12-04 03:37:29 26 4
gpt4 key购买 nike

假设我去了/unknown-route?a=hello&b=world,而$routeProvider无法识别它并重定向到其他路由:

otherwise({
redirectTo: '/default-route'
});

是否可以将给定的参数传递给重定向的路由。

这是 /default-route?a=hello&b=world

最佳答案

我找到了一个可行的解决方案:

otherwise({
redirectTo: function() {
return '/default-route' + location.search;
}
})

关于angularjs - 如何重定向$ routeProvider.otherwise()保持给定的查询参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25666556/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com