Angular 2 Routing run in new tab

前端 未结 5 1475
时光取名叫无心
时光取名叫无心 2020-11-29 06:49

I am working with a asp.net core application with angular2 and my routing is working fine.



        
5条回答
  •  执笔经年
    2020-11-29 07:29

    In my use case, I wanted to asynchronously retrieve a url, and then follow that url to an external resource in a new window. A directive seemed overkill because I don't need reusability, so I simply did:

    
    

    And in my component.ts

    navigateToResource(): void {
      this.service.getUrl((result: any) => window.open(result.url));
    }
    


    Note:

    Routing to a link indirectly like this will likely trigger the browser's popup blocker.

提交回复
热议问题