Encountering an issue with implementing an Iframe directive.
Status: Template:
<div class="externalIframe" iframe-src="external.html"></div>
Directive :
angular.module('project.directives', [])
.directive('externalIframe', ['$rootScope', function($rootScope) {
return {
restrict: 'C',
replace: true,
transclude: true,
scope: {
src: '@iframeSrc', // utilizing data-binding from parent scope
},
template: '<iframe src="{{src}}" height="100%" width="100%" frameborder="0"></iframe>',
link: function(scope, elem, attrs) {
//elem.src = "dummy.html"; // not working either
}
}
}])
Issue: Triggering 2 HTTP requests (2 iframe loading).
- one to
(iframe src not yet interpreted by angular)http://localhost:8000/app/{{src}}
- one to
(iframe src once interpreted by angular)http://localhost:8000/app/external.html
Looking to avoid the unnecessary first call. Any suggestions?
Attempted setting src programmatically in link or compile function with no luck in loading the iframe.
edit: jsFiddle added for bug demo with compile method => two requests are observed in network tab of firebug/chrome dev panel:
http://fiddle.jshell.net/_display/%7B%7Bsrc%7D%7D
http://fiddle.jshell.net/_display/external.html
Appreciate any assistance.