Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routing outside of application Angular2

I have an app in Angular2 and I need to navigate outside of app. I Have simple view:

...
<a [routerLink]="library.url" target="_blank" (click)="goToPage(library.url)">{{library.url}}</a>
...

and I want to navigate to library.url, I have method for navigation:

      goToPage(url: string)
      {
         //What should be here for navigation outside?
      }

Or exists another way to do that?

like image 493
Sergey Panov Avatar asked Oct 26 '25 14:10

Sergey Panov


1 Answers

you can set the global window-location of your Browser in your code, to navigate to your url:

goToPage(url: string): void {
    window.location.href = url;
}
like image 167
Chris Avatar answered Oct 28 '25 04:10

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!