Created
June 14, 2017 20:58
-
-
Save DevEarley/9272f96b0ed134e750f9323adbc3ecaf to your computer and use it in GitHub Desktop.
Angular Directive - easily bind a string of HTML.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('someApp').directive('bindHtml', ['$window', function () { | |
return function(scope, element, attr) { | |
element.addClass('ng-binding').data('$binding', attr.bindHtml); | |
scope.$watch(attr.bindHtml, function bindHtmlWatchHandler(value) { | |
element.html(value || ''); | |
}); | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment