在angular应用程序中使用javascript函数生成指向外部网站的链接

在angular应用程序中使用javascript函数生成指向外部网站的链接,javascript,html,angular,Javascript,Html,Angular,我有一个角度的应用程序。在index.html中,我有一些指向外部网站的链接标题 <a href="#" onclick="getUrl('about.html');">click here </a> 函数getUrl(链接) { 返回“https://external-domain.com/“+链接; } 但这并没有给我期望的结果,因为我的angular应用程序重定向到localhost:4200 我不知道为什么?尝试更

我有一个角度的应用程序。在index.html中,我有一些指向外部网站的链接标题

<a href="#" onclick="getUrl('about.html');">click here </a>


函数getUrl(链接)
{
返回“https://external-domain.com/“+链接;
}
但这并没有给我期望的结果,因为我的angular应用程序重定向到localhost:4200
我不知道为什么?

尝试更新getUrl函数,如下所示:

<script type="text/javascript">
    function getUrl(link)
    {
    window.location.href = "https://external-domain.com/"+link;
       
    }
</script>

函数getUrl(链接)
{
window.location.href=”https://external-domain.com/“+链接;
}

当您单击“单击此处”链接时,它将成功地将您重定向到外部网站。

这里有一些异味:为什么要将其放在index.html中?如果您有角度组件可以为您执行此操作,那么为什么要包含脚本标记呢。考虑为头创建一个头组件,并处理其中的内容
<script type="text/javascript">
    function getUrl(link)
    {
    window.location.href = "https://external-domain.com/"+link;
       
    }
</script>