I am certain this was asked before, but sadly all searches lead to questions relating to how to generate a download a file link (e.g. PDF etc)
My need is a bit different. Let's say I have a route, named /some-page
and upon clicking on it, instead of actually routing to it, I'd like it to be downloaded as an HTML page. Is this possible with latest Angular? Is there some way to intercept the routing somehow and do that?
Do I need to resort to dynamically compiling the view so I have a string (which I can trigger a download of), maybe something with NgComponentOutlet
?
e.g. I'm looking for something such as this imaginary syntax
<a [routerLink]="..." download="true" >
Or a way to render a component to string in runtime (I've seen a few options, but none of them feels too fun) then I can just follow the method here: How do I download a file with Angular2