Search Posts

Category: curly-braces

How to add an Angular expression (double curly braces) dynamically from a directive

I’m trying to add a custom attr. to an Html element with an Angular expression inside the directive’s compile function. However i can’t wrote the double curly braces because the ‘elem.attr()’ function deletes them. Any idea? Thanks in advance! function sbiLoading($compile, $timeout) { return { restrict: ‘A’, scope: {}, controller: function($scope) {}, compile: function(tElem, tAttrs) { return { pre: function(scope, iElem, iAttrs) { iElem.removeAttr(‘sbi-loading’); iElem.attr(‘loading-data’, ‘{{loadingData}}’); iElem.attr(‘class’, ‘loaded-main-wrapper’); var compiledElement = $compile(iElem)(scope); iElem.replaceWith(compiledElement); } }; […]