0

I am new to angular and looking for a solution where I can select a text file from a list of text files coming from back-end using a checkbox and display its content on click of a button let's say [View Content] in modal window or a dialog box.

The meta-data of all files visible is to be displayed in a table at front-end.

The backend API fetching the file details just provide the id,URL,fileName in json format displayed in a table and files are stored in the file repo lets say google drive.

Any working solution link will be helpful to understand the implementation.

1 Answers1

0

Just make a request and get the file by url using angular http client. And then you can use some library to display it according to the file type.

PS: Image can be fetched directly.

All2Pie
  • 310
  • 3
  • 13
  • The solution of using a third party document viewer service I have already tried and working fine but I am looking for a solution where I can show the content only in a modal window without using a third party service. Any good server-side open source library to achieve this is will also work..!! – Nishant Sharma May 12 '20 at 07:40
  • Only text file from the back-end API. – Nishant Sharma May 12 '20 at 12:12
  • `this.http.get("app/files/1.txt", { responseType: 'text' as 'json'}).subscribe(data => { console.log(data.text()); }) ` Try this. Source: https://stackoverflow.com/questions/47053328/angular-4-how-to-read-content-of-text-file-with-httpclient – All2Pie May 12 '20 at 12:33