I am writing an application which is part Anugular and part jQuery. I am separating them by loading the jQuery content in an iFrame.
Upon a certain event (say, upon a ng-click), I need to refresh the iFrame. My Controller contains the following code:
$scope.resfeshIframe = function() { //refresh the iFrame with id "anIframe" };
and the iFrame is:
<iframe id="anIframe" src="myUrl"></iframe>
Can someone help me with it. I can post more code if the required.
If you want to refresh all iframes from your page :
As Paulo Scardine said, the right way to do it would be through a directive cause you shouldn't use controllers to manipulate DOM.
Something like this one could do :
Which could then be used like :
And :
I did it in Angular 2 like that:
Another hack-ish solution: if you don't want to create a directive but want to stick to the good practices of not manipulating the DOM in controller. Keep the url in an array and use ng-repeat to render the iFrame: View:
Controller:
So, every time you set the value of the vm.url, angular will re-render the iFrame.
Solved it by a hack suggested in Reload an iframe with jQuery