I'm trying to make an Angular directive to wrap an iFrame. Because IE 11 doesn't support the srcdoc attribute I looked for a different way to fill the iFrame:
angular
.module('angularApp')
.directive('easyframe', easyframe);
function easyframe() {
return {
restrict: 'E',
scope: {content: '='},
replace: true,
template: '<iframe id="easyframe" width="100%"></iframe>',
controller: function ($sce, $scope, $element) {
$scope.$watch('content', function () {
var content = $sce.trustAsHtml($scope.content);
var iframeDocument = $element[0];
iframeDocument.open('text/html', 'replace');
iframeDocument.write(content);
iframeDocument.close();
});
}
};
}
This fails because the $element I get is a Angular jQueryLite object that doesn't have the open method. How do I get to the DOM element the Angular way, so without using querySelector?