Problem with print function in templates, specially in Twigs/AngularJs

Ask a question
6

Hi! I am new in AngularJs. I faced with the problem concerning print function in templates, specially in Twigs. AngularJs and Twig use the same ‘{{‘ ,’}}’ symbols to print something. Please help me to solve this problem. Thanks in advance.

Coin iconoffer bounty
add comment

2 Answers

6

In AngularJs you are allowed to change the print symbols and set another symbols whatever you want.You can use [[ ]], [{ }], {{{ }}}, // // etc…Its called Interpolation.You can create an angulars module for that changing and inject it wherever you want.Here is how you can do that:
angular.module("Interpolation",[]) .config(["$interpolateProvider",function($interpolateProvider){ $interpolateProvider.startSymbol("[["); $interpolateProvider.endSymbol("]]"); }])
Source: https://www.w3docs.com/snippets/angularjs/angularjs-and-symbols-conflict-with-twig.html

Thank you so much, Jack

Sara
add comment
3

You should use Verbatim, put AngularJs print function inside {% verbatim %}{% endverbatim %} block

add comment

Your Answer