I am trying to modify an Angular template before any other directive is triggered, in particular interpolation. I am doing this through the compile option in the directive definition.
Here is my test code:
<!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js"></script> <script> angular.module('soQuestion', []) .directive('example', function () { return { compile: function (tElement, tAttrs) { if (tAttrs.foo && tAttrs.foo.match(/^keyword/)) { tElement.attr('foo', 'prefix-' + tAttrs.foo); console.log(tElement.attr('foo')); } } }; }) .controller('controller', function($scope) { $scope.value = 'something'; }); </script> </head> <body ng-app="soQuestion"> <div ng-controller="controller"> <div example foo="keyword_{{value}}"></div> </div> </body> </html> However, the final result that I get is <div foo="keyword_something"></div> instead of <div foo="prefix-keyword_something"></div>, even if the compile function was triggered properly. What is going on here?