0

I have a json array that I iterate through like so...

<div class="panel panel-primary" ng-repeat="c in components">
    <div class="panel-body">
        <h2>{{c.title}}</h2>
        <div ng-include="c.template"></div>
    </div>
</div>

The ng-include loads the html template file, i.e. 'components/blockquote.html'

Is there a way to also load the source code from that html file as well, so you can show the component next to the source in an element like so..

<div class="panel panel-primary" ng-repeat="c in components">
    <div class="panel-body">
        <h2>{{c.title}}</h2>
        <div ng-include="c.template"></div>
        <code>
          <blockquote>
            <p>This text is quoted.
          </blockquote>
        </code>
    </div>
</div>
1
  • You probably could have used <xmp ng-include="c.template"></xmp> but xmp tag is deprecated. I can't find a better solution, did you find any? Commented Aug 31, 2016 at 13:12

1 Answer 1

0

Since you know the template url, you could load it using AJAX like you would load any other (e.g. json) resource. Then you can simply display it in your template and will show the actual html code since by default it will be treated as a unsafe html.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.