Angular 2 - Redirect to an external URL and open in a new tab

前端 未结 9 678
离开以前
离开以前 2020-12-03 00:36

I\'m trying to Open a new page when user clicks on a link. I can\'t use Angular 2 Router, because it doesn\'t have any functionalities to redirect to an external URL.

<
9条回答
  •  被撕碎了的回忆
    2020-12-03 01:12

    you can do like this in your typescript code

    onNavigate(){
    var location="https://google.com",
    }
    

    In your html code add an anchor tag and pass that variable(location)

    Redirect Location
    

    Suppose you have url like this www.google.com without http and you are not getting redirected to the given url then add http:// to the location like this

    var location = 'http://'+ www.google.com
    

提交回复
热议问题