1

I want to create a angular form generator. I have template like this:

<script type="text/ng-template" id="textarea.html">
    <div class="items form-group">
        <label class="col-sm-2 control-label">
            {{item.title}}
        </label>
        <div class="col-sm-10">
            <textarea ng-model="task.title" placeholder="{{item.placeholder}}" class="form-control"></textarea>
        </div>
    </div>
</script>

and when user add this template that generate Angular html code like this:

    <div class="items form-group">
        <label class="col-sm-2 control-label">
            {{item.title}}
        </label>
        <div class="col-sm-10">
            <textarea ng-model="task.title" placeholder="{{item.placeholder}}" class="form-control"></textarea>
        </div>
    </div>

With this example my template code rendered but I don't want render it and just show angular html code. If you have any suggestion, please change this code.

Example Code

2 Answers 2

1

you can use ng-bind instead of ng-include;

example:

**in app.js.**

app.run(['$injector', function($injector) {
  var rootScope = $injector.get('$rootScope');

  rootScope.tpl = '<h1 style="color:green;">This is the page content</h1>';
}])

**in index.js**

<span ng-bind='tpl'></span>
Sign up to request clarification or add additional context in comments.

2 Comments

How to assign template to $injector. I have many template that include with name of this and can't put in app.run(....).
you can use $templateCache service to obtain template which is the content of script directive
0

If you use normal tags it will render but if you don't want to render it then you can use

replace < by &lt; and > by &gt;

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.