Angular JS custom delimiter

JavascriptAngularjsConfigurationDelimiter

Javascript Problem Overview


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?

Javascript Solutions


Solution 1 - Javascript

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAzri JamilView Question on Stackoverflow
Solution 1 - Javascriptpkozlowski.opensourceView Answer on Stackoverflow