title: Angular 2 - Open URL in New Window with POST
body: <p>I currently have a component that requires to have a pop up upon submit. The response from the API provides a redirectURL and redirectParams to be used as the popped up window.</p>
  
  <p>Simply using <code>window.open</code> defaults its method to <code>GET</code> and not <code>POST</code>. This causes a <code>Not Found</code> page whenever it is loaded this way.</p>
  
  <p>This is how I currently do it:</p>
  
  <pre><code>protected makeDepositPopup(depositRequest: PaymentRequest) {
      this.depositService.requestDepositPopup(depositRequest)
          .subscribe(
              (depositEvent: RedirectData | SuccessfulDepositPopup) =&gt; this.handleDepositPopupEvent(depositEvent),
              (error: EcommError) =&gt; this.handleDepositError(error),
              () =&gt; this.eventService.depositAttempt.emit()
          );
  }
  </code></pre>
  
  <p>then the event is handled via the handleDeposit event:</p>
  
  <pre><code>protected handleDepositPopupEvent(depositEvent: RedirectData | SuccessfulDepositPopup) {
      if (depositEvent instanceof RedirectData) {
          this.handleRedirect(depositEvent);
      } else {
          this.handleDepositSuccessPopup(depositEvent, this.redirectParams);
      }
  }
  </code></pre>
  
  <p>As soon as it succeeds, it then tries to open a window with the corresponding URL and parameters provided by the API response:</p>
  
  <pre><code>protected handleDepositSuccessPopup(depositEvent: SuccessfulDepositPopup, redirectParams: string): void {
      redirectParams = ""; // to remove undefined value
      depositEvent.params.forEach(function (data, index) {
          if(index == 0) {
             redirectParams += "?" + data["key"] + "=" + data["value"];
          } else {
             redirectParams += "&amp;" + data["key"] + "=" + data["value"];
          }
      });
  
      window.open(depositEvent.url + redirectParams);
      this.router.navigate(
          ["deposit", this.route.snapshot.data["instrumentTypeCode"], "deposit-details", depositEvent.id], {
              relativeTo: this.route.parent.parent
          });
  }
  </code></pre>
  
  <p>How do I convert this in such a way that the <code>depositEvent.url</code> and its appended <code>redirectParams</code> to open a new window with a <code>POST</code> method to get a successful page response?</p>