Reputation: 776
I trying into download static file from HTML .It's not working
app.routing.ts
{ path: 'application', component: ApplicationComponent},
// otherwise redirect to home
{ path: '**', redirectTo: '/home' }
html
<a href="/excel_files/xxx.xlsx" target="_self" class="btn btn-primary"><i class="fa fa-download"></i> Download Spread Sheet</a>
Here is link - http://localhost:4200/excel_files/xxx.xlsx
But it's redirect into home.
Thanks.
Upvotes: 1
Views: 2324
Reputation: 3483
Here the answer
Please add the download attribute to the tag. This will prevent rout changes and tell the browser it is a download link:
<a href="/excel_files/file_name.xlsx" target="_self" download>
<i class="fa fa-download"></i> Download Spread Sheet
</a>
Upvotes: 5