0

I have an iframe that I use to contain a file upload form:

<iframe name="fileUploadCallback" style=" border: 0; width : 100%;" ng-src="{{uploadIframeSrc}}"></iframe>

In the controller, I set the uploadIframeSrc to some html page on the server that contains the file upload form.

On the submit, the form is sent to the server and the server redirects the Location to another webpage that is also on the server.

In that returned webpage, I have a button to reset the iframe to point at the original form. I used this code to achieve it:

//button.onClick
this.parent.angular.element('iFrame').scope().uploadIframeSrc = "/original/form.html"

This doesn't work. In fact, when I try to call a method set the $scope.uploadIframeSrc, it doens't work, even though when I call the same mehod from the controller when the page first loads, it works.

this.parent.angular.element('iFrame').scope().setIFrameSrc();

I suspect that the ng-src directive has been replaced by the HTTP header-location, and as such setting the scope variable to the new URI doesn't have an effect.

Is there a way to restore the ng-src directive?

EDIT 1: I also tried returning a raw HTML insteat of a HTTP redirect.

If the answer to the original questin is No, is there a way to try to have the server return something while allowing the iframe to retain the linkage with the scope variable?

Sinker
  • 578
  • 1
  • 9
  • 20
  • Possible duplicate of [How to set an iframe src attribute from a variable in AngularJS](http://stackoverflow.com/questions/20045150/how-to-set-an-iframe-src-attribute-from-a-variable-in-angularjs) – misha130 May 11 '16 at 06:01
  • @misha130 - do I need to use `$sce` if the links are server resources? It seems that the question you mentioned is related to the missing injection of `$sce – Sinker May 11 '16 at 06:07
  • @Sinker Have you tried with just `ng-src="uploadIframeSrc"`? – Arg0n May 11 '16 at 06:12
  • @Arg0n - I changed the code, and did a complete redeploy along with browser cache clearing. The result was that TomCat return a 404 `/appName/uploadIframeSrc - the requested resource is not available.` – Sinker May 11 '16 at 06:20

0 Answers0