AngularJS$routeProvider会捕获我的外部重定向
我在AngularJS中使用$routeProvider配置了许多路由。另一部分 已配置,因此它会将所有未知路由重定向到我的应用程序主页面 我只想将浏览器从我的控制器重定向到一个外部URL,但我做不到。 我尝试使用$window.location=external、window.location.href=external,但它们不起作用。路由API每次都会将我重定向到“否则”中设置的默认页面 我如何在有或没有重大黑客的情况下实现这一点。不幸的是,它必须通过我的控制器中的JavaScript代码来完成AngularJS$routeProvider会捕获我的外部重定向,angularjs,redirect,routing,external,Angularjs,Redirect,Routing,External,我在AngularJS中使用$routeProvider配置了许多路由。另一部分 已配置,因此它会将所有未知路由重定向到我的应用程序主页面 我只想将浏览器从我的控制器重定向到一个外部URL,但我做不到。 我尝试使用$window.location=external、window.location.href=external,但它们不起作用。路由API每次都会将我重定向到“否则”中设置的默认页面 我如何在有或没有重大黑客的情况下实现这一点。不幸的是,它必须通过我的控制器中的JavaScript代码
提前感谢AngularJS的路由是用于页面内的路由 您应该为此使用native location.href 编辑:你能给我一个打折吗?你试过这方面的东西了吗 $scope.path=http://www.google.com; $scope.redirect=functionpath{ location.href=路径; }; 与
这可能无法完全回答您的问题,但要在路由范围之外导航,您可以使用此选项
Links that contain target element
Example: <a href="/ext/link?a=b" target="_self">link</a>
Absolute links that go to a different domain
Example: <a href="http://angularjs.org/">link</a> //this one might actually be of use for you
Links starting with '/' that lead to a different base path when base is defined
Example: <a href="/not-my-base/link">link</a>
我不能。它没有效果,将我重定向到$routeProvider的其他部分中定义的主页。谢谢,这很有效-我知道,但我必须从控制器中的JavaScript代码重定向。
Links that contain target element
Example: <a href="/ext/link?a=b" target="_self">link</a>
Absolute links that go to a different domain
Example: <a href="http://angularjs.org/">link</a> //this one might actually be of use for you
Links starting with '/' that lead to a different base path when base is defined
Example: <a href="/not-my-base/link">link</a>