Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to route/link to a PDF file in Angular 2?

I'm trying to retrieve a client side pdf file to display in the browser. Tried your normal href, path relative to the html file, and it doesn't work.

<a href="../assets/file.pdf>Get File</a>

And using routing doesn't work either, or I'm not using the right tag...

RouterModule.forRoot([
  { path:"resume", redirectTo: '../assets/file.pdf' },
  { path: '', component: AppComponent }
])

Not sure if Routing is the way to go either, I have only learned to route components based on their documentation.

like image 471
wpakt Avatar asked Oct 09 '16 16:10

wpakt


Video Answer


1 Answers

<a href=".. should work. I think the problem is the path for your pdf file. Did you try <a href="/assets/file.pdf>, instead of ../assets?

like image 54
Edmar Miyake Avatar answered Sep 29 '22 23:09

Edmar Miyake