AngularJS - How to fetch PDFs (or other binary files) from rails backend?
angularjs, ruby-on-rails
Solution
One way is just use an anchor tag in HTML and put the link as a controller variable ie. `<a href="{{link}}">Download</a>` and in controller put $scope.link = "http://localhost..."; (or array if requiring multiple links).
If this is not what you want, please add further clarification.
Problem
I'm writing a toy application to get acquainted with AngularJS. This application has a Rails backend. I don't know how to make the client side angularjs app, deal with a PDF that the backend sends when hitting a particular URL (http://localhost:3000/contacts.pdf) When typing the above mentioned URL straight in the browser, the server replies with a PDF and the browser asks what to do with it (download or open). When the same thing is done via the angularjs app, I can see the file gets returned in the response. And that's where I'm stuck at. How can I replicate the same behaviour within client side app? Thanks for your help