How to write confusing angular - Changing the default angular delimiter.

I just spent a wasted hour trying to figure out why an angular app written by one of my employers contracts was behaving so strangely. Apparently in angular you can override the default {{}} delimiter like so:

var myApp = angular.module('myApp', [], function($interpolateProvider) {
    $interpolateProvider.startSymbol('[[');
    $interpolateProvider.endSymbol(']]');
});
You would now define a template{{ var }} as [[ var ]]

Check the documentation on the $interpolate service here: http://docs.angularjs.org/api/ng.$interpolate
I really can't think of a reason why you would want to do this offhand - unless you are trying to be a troll Javascript hipster!

Great trap for young players.

No comments:

Post a Comment