65

How do I use a custom delimiter for angular JS? I'd like to change from the {{ var }} syntax to [[ var ]].

Can somebody show me a complete example on how to implement this with Angular?

1 Answer 1

106

You can use $interpolateProvider to change start / end symbols used for AngularJS expressions:

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

and then, in your template:

Hello, [[name]]

Here is the working jsFiddle: http://jsfiddle.net/Bvc62/3/

Check the documentation on the $interpolate service here: http://docs.angularjs.org/api/ng.$interpolate

Sign up to request clarification or add additional context in comments.

9 Comments

Tried still not working in my app, nothing happen angular still looking for {{ }} bracket.
Could you try to compare what is goin on in the setup of your web app to the fiddle I've sent? As you can see it works ok in the fiddle in the response. Watch out for code around module initialization. Are you specifing ng-app="myApp" like in the jsfiddle?
Hi, how do we configure the custom brackets for modules like bootstrap.ui?`
Does anyone know if there's an "official" fallback startSymbol and endSymbol that the community prefers to see?
You can put the start and end symbols in one line now. Like this --> $interpolateProvider.startSymbol('[[').endSymbol(']]');
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.