javascript - Angular JS 1中的$ location:badpath时如何将url重定向到默认值
问题描述
当我输入一个 '\' 之后是另一个 '\' 的 url 时。例如:http://localhost:8080/#!//test。它将产生 $location:badpath 的错误。如果用户这样做,如何将其重定向到默认路由?
app.config(function ($routeProvider, $httpProvider) {
$routeProvider
.when('/test', {
templateUrl: 'project/view/test.html',
controller: 'TestController'
})
.otherwise(
{
redirectTo: '/dashboard'
}
);
解决方案
推荐阅读
- java - 生命周期错误未涵盖插件执行
- docker - Docker 立即退出
- reactjs - 我不明白为什么在这个例子中我的组件被调用了两次
- javascript - String.localeCompare 返回不正确的值?
- carousel - 在引导程序 myCarousel 中拉伸的图像
- reporting-services - 引用“无”时切换功能未返回正确值
- django - 将 2 个缓存条目合并为一个
- wordpress - 在其他用户不工作的情况下在 Mac 上运行 XAMPP
- javascript - 有没有办法从两个范围输入中获取值并给方程一个自定义值?
- javascript - 在映射之前按属性对对象数组进行排序