angular js 和 dajango 标签{{}} 冲突

Posted @old土哥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了angular js 和 dajango 标签{{}} 冲突相关的知识,希望对你有一定的参考价值。

问题描述:

如果在django的模板中使用{{ }},不会被angularjs 识别。

 

解决办法:

>1.5 的django中,将需要angularjs解释的{{expression}}放在 verbatim模板标签中

{% verbatim %}

{{ vm.name }}

{% endverbatim %}

 

注意:

Keep in mind two things:

  • mixing server-side and client-side templates is rarely a good idea and should be used with caution. The main issues are: maintainability (hard to read) and security (double interpolation could expose a new security vector - e.g. while escaping of serverside and clientside templating by themselves might be secure, their combination might not be).
  • if you start using third-party directives (components) that use {{ }} in their templates then your configuration will break them. (fix pending)

参考:http://stackoverflow.com/questions/8302928/angularjs-with-django-conflicting-template-tags

{% verbatim %}


{{if dying}}Still alive.{{/if}}{% endverbatim %}



以上是关于angular js 和 dajango 标签{{}} 冲突的主要内容,如果未能解决你的问题,请参考以下文章

angular打包后在其他前端项目中引用

Angular.js - 在 img src 标签中过滤

Angular.js数据绑定时自动转义html标签及内容

Angular JS - 6 - Angular JS 常用指令

Angular js 将变量绑定到标签 <text x =

使用Angular JS时如何在ng-repeat内的img标签中显示图像?