How to resolve the conflict between Angularjs and Django?

Asked

Viewed 130 times

4

What is the most efficient way to solve the conflict problem between Django and Angularjs when using {{ }} in the templates?

  • The only way is to change the source code of one of the two, so that for example Angular recognizes [[ ]] and Django {{ }}.

1 answer

4


Angularjs provides tools for setting markers via $interpolateProvider. For example, if you want to use [[ and ]] as markers, use the following snippet:

var myApp = angular.module('myApp', [], function($interpolateProvider) {
    $interpolateProvider.startSymbol('[[');
    $interpolateProvider.endSymbol(']]');
});

Source of the snippet: https://stackoverflow.com/questions/12923521/angular-js-custom-delimiter

  • Just watch out for the symbols you use as markers, so you don’t create something like this: <span>[[array[myIndex]]]</span> (in a line already gets strange, imagine in several).

  • 1

    @Correct Fernando - in theory you can use any combination, including some that are only partial changes such as {* and *}.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.