Routing outside of application Angular2

霸气de小男生 提交于 2019-12-25 08:09:59

问题


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?


回答1:


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;
}


来源:https://stackoverflow.com/questions/39912264/routing-outside-of-application-angular2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!