Skip to content

Instantly share code, notes, and snippets.

@DevEarley
Created June 14, 2017 20:58
Show Gist options
  • Save DevEarley/9272f96b0ed134e750f9323adbc3ecaf to your computer and use it in GitHub Desktop.
Save DevEarley/9272f96b0ed134e750f9323adbc3ecaf to your computer and use it in GitHub Desktop.
Angular Directive - easily bind a string of HTML.
'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