How to resolve an expression before iFrame is loaded?

1,919 views
Skip to first unread message

Roman Sachse

unread,
Sep 18, 2012, 6:52:14 AM9/18/12
to ang...@googlegroups.com
Hi there,

I am creating iframes via ngRepeat. Each iframe receives a name dynamically:
<div ng-repeat="widget in workspace.widgets">
    <iframe name="{{widget.instance_identifier}}" ng-src="{{widget.instance.url}}" width={{widget.instance.width}} height={{widget.instance.height}}></iframe>
</div>

The problem is that the name is not resolved before the iframe is loaded.
In my iframe (another angular app) I do:
console.log($window.name) but the result is always the literal {{widget.instance_identifier}}.

In the container of the iframe the name is correctly resolved, so I get:
<iframe  name="505849e578e27" ng-src="http://bla:8080/wookie/...

Is there a way to resolve the name before the iframe is loaded (something similar to ngSrc)

Thanks,

Roman


James Wright

unread,
Sep 18, 2012, 9:00:08 AM9/18/12
to ang...@googlegroups.com
Could you consider using a different architecture where you have scrolling divs instead of new iframes? then you wouldn't be loading up the angular inside each iframe.

I don't know the answer to your question, sorry.

Roman Sachse

unread,
Sep 18, 2012, 11:01:59 AM9/18/12
to ang...@googlegroups.com
No, unfortunately this is not possible. I am developing an application based on w3c Widgets which are served by an apache wookie server. The widgets can be full applications by themselves (using Angular or plain js or whatever), so I dont see how this could be achieved without iframes.

I only need to defer the loading of the iframe until the the expression in the name attribute is resolved.

Ricardo Bin

unread,
Sep 19, 2012, 10:33:52 AM9/19/12
to ang...@googlegroups.com
Hello,

You can use the ng-bind-html-unsafe directive, to render the iframe and innerHTML it, instead of use iframe markup with ng-src.

See this plunker ;D

Roman Sachse

unread,
Sep 20, 2012, 4:50:47 AM9/20/12
to ang...@googlegroups.com
Thanks a million!!! This was a real show stopper for me.
Reply all
Reply to author
Forward
0 new messages