Friday, October 31, 2014

AngularJS & Download File using WebAPI

As you know AngularJS routing overwrites the relative urls in a hyperlink so that AngularJS can handle all the requests. This sometimes causes problems. In my scenario I want to download a file when user clicks on a hyperlink in my grid. AngularJS is not sending this request to the server as a result I am unable to serve the file user wants to download.

Here is my hyperlink code that I used in the grid.

<a href="/api/download/1">Download File</a>

As you see the above hyperlink calls an webapi which in turns returns a word document that needs to be downloaded. As mentioned above clicking on this hyperlink does not download the file.
The solution for this issue is very simple, we just need to specify the target of the “a” tag as shown below

<a target="_self" href="/api/download/1">Download File</a>

Please see my other blog on how to download a file from Web API


18 comments:

  1. Salesforce CRM offers enhanced management of end-to-end customer relationship management. Salesforce training in Hyderabad

    ReplyDelete
  2. Online slots (Slot Online) is the launch of a gambling machine. Slot machine As stated above Used to make electronic games referred to as web-based slots, due to the development era, many people have turned to gamble with one another by computers. Will draw slot games to make web based gambling games Via the web network system Which players can play through the slot plan or will perform Slots through the service provider's site Which internet slots games are available in the form of participating in guidelines. It is similar to playing on a slot machine. Both realistic pictures as well as sounds are at the same time thrilling as they go to lounge in the casino ever.
    บาคาร่า
    ufa
    ufabet
    แทงบอล
    แทงบอล
    แทงบอล

    ReplyDelete