AngularJS with Django - Conflicting template tags

前端 未结 12 2321
南笙
南笙 2020-11-22 13:39

I want to use AngularJS with Django however they both use {{ }} as their template tags. Is there an easy way to change one of the two to use some other custom

12条回答
  •  鱼传尺愫
    2020-11-22 14:06

    I vote against using double parentheses (()) as template tag. It may work well as long as no function call is involved but when tried the following

    ng:disabled=(($invalidWidgets.visible()))
    

    with Firefox (10.0.2) on Mac I got a terribly long error instead of the intended logic. <[]> went well for me, at least up until now.

    Edit 2012-03-29: Please note that $invalidWidgets is deprecated. However I'd still use another wrapper than double braces. For any angular version higher than 0.10.7 (I guess) you could change the wrapper a lot easier in your app / module definition:

    angular.module('YourAppName', [], function ($interpolateProvider) {
        $interpolateProvider.startSymbol('<[');
        $interpolateProvider.endSymbol(']>');
    }); 
    

    API docs.

提交回复
热议问题