Already have the file address returned by the backend, how to control the browser download?

I did this before: click the "download" button, and the backend will return the file address, then change the value of downloadUrl to download successfully

<a class="link" href="{{downloadUrl}}" ng-click="download()"></a>

is there any other way? I always feel so stupid.

Mar.18,2021

you can download


by opening the new page directly in the click method.

try location.href = downloadUrl

.
Menu