How to make Angular work with Jinja templates

I use Jinja templates for my frontend development. When trying to use Angular code it failed as it tryied to compile it as Jinja.

In order to avoid conflict simply wrap it in a raw Jinja block. This will leave the curly braces intact when compiling the template.

{%raw%}
<input type="text" ng-model="yourName" placeholder="Enter a name here">

<h1>Hello {{yourName}}!</h1>
{%endraw%}Code language: HTML, XML (xml)

Comments

  1. We can modify an angularjs’s syntax like below

    app.config(function($interpolateProvider) {
        $interpolateProvider.startSymbol('$$');
        $interpolateProvider.endSymbol('$$');
      });
    Code language: PHP (php)

    Based on the above you can use

    $$yourvalue$$Code language: PHP (php)

    for angularjs data binding

Leave a Reply

Your email address will not be published. Required fields are marked *