1

I am trying to create a download function in my angularjs using a url link ( not a json ) For example: https://assets.onemap.sg/shp/historicsites.zip How can i do so ?

PS: Another question @the comment

 <button ng-click="download">
 </button>
4
  • use a download attribute: <a href="https://assets.onemap.sg/shp/historicsites.zip" download> Commented Oct 24, 2018 at 8:42
  • oh wow cool, thanks. Just another question, is it possible to change the url after the /shp/ like assets.onemap.sg/shp/abc.zip (abc.zip) to assets.onemap.sg/shp/def.zip (def.zip) Commented Oct 24, 2018 at 8:45
  • On page load, suppose from x place you are getting this dynamic url then assign URL in a variable and bind it in a href attribute. Commented Oct 24, 2018 at 8:47
  • Do you mind elaborating more on that? @UtkarshDubey please and thanks! Commented Oct 24, 2018 at 8:48

1 Answer 1

1

Use download attribute in <a> tag

<a href="https://assets.onemap.sg/shp/historicsites.zip" download>

If you want to change the url, do

<a ng-href="https://assets.onemap.sg/shp/{{fileName.zip}}" download>link1</a>
Sign up to request clarification or add additional context in comments.

1 Comment

That did the trick, thanks! But i am getting this error on my console log, any idea how to fix it? "Resource interpreted as Document but transferred with MIME type application/zip:"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.