title: Download image from url in Angular 5
body: <p>I have an URL in which the image that I need to download is.
  I want to make a button to download it.
  I tried this two options:</p>
  <pre class="lang-js prettyprint-override"><code>    const a = document.createElement('a');
          a.href = ImageURL;
          a.download = title;
          document.body.appendChild(a);
          a.click();
  </code></pre>
  <p>and</p>
  <pre class="lang-js prettyprint-override"><code>     window.location.href = t;
  </code></pre>
  <p>But both options just open a new window with the image.</p>
  <p>Is there a way to instead of getting a new window the file just get downloaded?</p>