Salman Shaykh
Salman Shaykh

Reputation: 221

Angular JS file download

I am trying to download file on a link click following this stackoverflow question Angularjs simple file download. After i click the link file downloads with error saying Failed No file. I have checked projects App_Data folder file is present there. Can anyone help figure out the issue.

 <a target="_self" download="{{q.FileName}}" ng-href="{{q.QuizFile}}" href="#">Open File</a>

It renders into this path...

<a target="_self" download="Discussion.docx" ng-href="~/App_Data/74edf10b-5c18-472f-92bb-c64f55575b29/Discussion.docx" href="~/App_Data/74edf10b-5c18-472f-92bb-c64f55575b29/Discussion.docx">Open File</a>

Upvotes: 0

Views: 610

Answers (1)

Nick Bailey
Nick Bailey

Reputation: 3162

The tilde in the path name doesn't mean anything in JavaScript. Its a convenience in mvc that resolves server side. Pass the path without the tilde.

Upvotes: 2

Related Questions