首页 > 解决方案 > 使用 $location.path 重定向到另一个 url

问题描述

我必须从我的实际网页重定向到新的 url,我从后端的响应中获取 url。

var url = res.response.data.link;
$location.url(url);

但是我的网址附加了我的本地主机网址,如何避免这种情况

http://127.0.0.1:50966/index.html#/https://www.paypal.com

标签: angularjs

解决方案


使用$window而不是window,还要确保你也在$window注入controller

$window.location.href = url;

推荐阅读