如何读取文本文件并以html(angularjs)显示 [英] how to read a text file and display it in html (angularjs)

查看:83
本文介绍了如何读取文本文件并以html(angularjs)显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用angularjs,并且在文本文件中有一个使用条款文档,该文档将呈现为html.关于如何阅读该文本文件并使用html显示或向用户显示的任何建议?谢谢

I am using angularjs and i have a terms of use document in a text file which i was to render into html. Any recommendations on how to read that text file and display it using html or display it to the user? Thanks

推荐答案

最简单的方法是使用 ng-include .如果需要在视图中的文本文件中使用换行符,请使用< pre> 标记

Simplest way is using ng-include. If you need to use the line breaks in the text file within your view wrap in a <pre> tag

<h3>Terms</h3>
<ng-include src="'terms.txt'"></ng-include>

OR

<pre ng-include src="'terms.txt'"></pre>

演示

这篇关于如何读取文本文件并以html(angularjs)显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆