diff --git a/bindonce.js b/bindonce.js index 3a6f43d..c1970f8 100644 --- a/bindonce.js +++ b/bindonce.js @@ -35,8 +35,9 @@ var bindonceDirective = { restrict: "AM", - controller: ['$scope', '$element', '$attrs', '$interpolate', function ($scope, $element, $attrs, $interpolate) + controller: ['$scope', '$element', '$attrs', '$interpolate', '$injector', '$sce', function ($scope, $element, $attrs, $interpolate, $injector, $sce) { + var sanitize = $injector.has('$sanitize'); var showHideBinder = function (elm, attr, value) { var show = (attr === 'show') ? '' : 'none'; @@ -180,7 +181,7 @@ binder.element.text(value); break; case 'html': - binder.element.html(value); + binder.element.html(sanitize ? $sce.getTrustedHtml(value) : value); break; case 'style': binder.element.css(value);