1

I have the textarea contains the html code and some template jinja2 directives. So as you might guess the javascript crashed on page load, because Angular find some directives from jinja2 inappropriate ( for example {{ variable }} ). I mean these directives might be valid for Angular, but they are not event in a $scope, something like that...

I added recommended Angular directive ngBindTemplate both to textarea and even to div-wrapper, but this doesn't work.

Here is some source code from the browser:

<textarea id="body" name="body" ng-non-bindable="">&lt;!DOCTYPE html&gt;
&lt;html lang="ru"&gt;
&lt;head&gt;
    &lt;meta charset="utf-8" /&gt;

    &lt;link rel="icon" href="/static/images/favicon.ico" type="image/x-icon" /&gt;
    &lt;link rel="shortcut icon" href="/static/images/favicon.ico" type="image/x-icon" /&gt; 

    &lt;title&gt;{% block title %}Title{% endblock %}&lt;/title&gt;


    &lt;link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" /&gt;

    &lt;link rel="stylesheet" href="/static/css/styles.css" type="text/css" media="all" /&gt;
&lt;/head&gt;
&lt;body&gt;
.....
</textarea>

As you can see the html inside textarea is escaped, but seems it make no sense to AngularJS and it compiles the content anyway.

4
  • When you use ng-app to load a module onto a portion of the DOM you're basically telling angular to process anything that happens within the descendants of that element. You can change the characters used for angular interpolation if that helps you. Commented Apr 1, 2014 at 22:02
  • I also suggest looking into ng-bind-html ng-bind $sce and ngSanitize since it will probably all apply though it's difficult to grock exactly what you're trying to achieve. Do you want it to just show the HTML as plain text or do you want to use the HTML to be interpreted by the browser? Also really what's the end goal? Why mix two things with templating, why have the backend touch the front-end at all? The service layer should just be RESTful and communicate with JSON so parts can be rebuilt and re-used. Commented Apr 1, 2014 at 22:13
  • I'm building the Administration Interface where I have the ability to edit site templates. Template engine is Jinja2. So I just displaying the textarea with the html + jinja2 code in it for editing. Commented Apr 2, 2014 at 8:20
  • If somebody interested, I solved my problem simply by changing AngularJS delimiters. stackoverflow.com/questions/12923521/… Commented Apr 3, 2014 at 16:37

0

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.