-1

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

1

1 Answer 1

6

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>

DEMO

Sign up to request clarification or add additional context in comments.

5 Comments

@Charlieti thanks for the demo above. It works well. But i cant get it to work on my side. here is the code i have and it shows a jumbuton-like area with a grey color and nothing inside. It also scrolls up and down but its all grey. I dont why . <div ng-controller="FooterCtrl"> <h3>Terms</h3></p> <pre><ng-include src="'terms.txt'"></ng-include></pre> </div>
not the extra quotes inside src .. looks strange but is needed if want to load from server url
yes sorry, i tried that too
not sure why...is that the right path to the file? Can inspect the actual ajax request in browser dev tools network tab to see if it is made and succeeds and what is returned
I always get the error that ng-include is not a known element.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.