简体   繁体   中英

How to display the content of a file in Angular 9?

I have an Angular App, and the user uploads two files there, json and xml. What I want to do is show the contents of the file. I have tried one approach, processing the file line by line and adding it to a string and then show the string. But that way I lose the indentation and other things too. Is there any way I can show the uploaded file directly without having to go all the trouble. And I have one more thing to do, I have a list of line number and I want to maybe add custom color to that line numbers. eg [2,3,4] is the list of line number, and so in the uploaded file, I would like to color line numbers 2,3,4 as red. How can I do all this?

The iFrame tag is often a good way to simply display files, but I don't have experiences in using the iFrame tag with JSON or XML files and it would not directly solve your problem of modifying them...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM