如何创建回调URL-Angular

时间:2019-06-19 04:00:09

标签: angular angular-routing

如何创建回调URL?

我正在尝试根据与Angular应用程序的安全性相关的一些要求创建一个回调URL。将应用程序的位置更改为回调URL后,需要检查URL以查看其是否具有错误的哈希值。

  isAuthorized(): boolean {
      if (!this.hasSession()) {
        this.authService.login();
      } else {
        const deepLink = this.getCookie('DeepLink');
        //do something
      }
  }

  hasSession(): boolean {
    let URL = 'https://';
    for (var property in this.dualLogonAPI) {
      if (this.dualLogonAPI.hasOwnProperty(property)) {
        URL += this.dualLogonAPI[property];
      }
    }

    // this.router
    //   .navigate([URL])
    //   .then(/*...*/)
    //   .catch(/*...*/);
    return true;
   }

 canActivate(): boolean {
    return this.isAuthorized();
  }

我已经将HashLocationStrategy添加到我的 app.module.ts

1 个答案:

答案 0 :(得分:0)

路由器仅在您的路线上导航,我看到您需要点击一些外部网址,因此取决于您要实现的目标:

location.href = URL

它将重定向到Terget页面,或

HttpClient#get