1

I have an Angular 5 project that allows for a file upload, and I'd like to give the user an example/template file they can download first.

File structure

file-importer/ | file-importer.component.html | file-importer.component.ts | example-file-template.csv 

In that HTML file I want to do something like this

<a href='example-file-template.csv' download> Download a sample template here </a> 

But that link will be incorrect, so how am I supposed to link to static files like this?

1 Answer 1

5

Put your static files in the /assets folder. It's a special folder in Angular, that's where you're supposed to put all your static files, images etc. Then link them like this :

<a href='assets/example-file-template.csv' download> Download a sample template here </a> 
Sign up to request clarification or add additional context in comments.

4 Comments

Makes sense, thanks! I never really used that folder before.
how to prevent event bubbling here?
Is this folder hardcoded into Angular or can we chose from where to serve static assets?
Didn't work for me! Downloaded file is replace with the content of index.html

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.