Search Posts

Category: attributes

Force angularjs attribute directive to not parse its value

I am making an attribute directive that will work similarly to ng-if. window-match-media=”(min-width: 400px)” which will make the element render if the media query matches and disappear otherwise. I am modeling my directive on the code for ngIf It works great with the exception that I have to currently enclose the media query in an extra pair of quotes. This is because without it, it seems to try to parse the attribute value. This makes […]

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); } }; […]