Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat happens when removing an object used by a ngRepeat in AngularJS?
    primarykey
    data
    text
    <p><strong>EDIT: <a href="http://jsfiddle.net/eJTFe/1/" rel="nofollow">jsFiddle</a> example here.</strong></p> <p>I have a <code>ngRepeat</code> that spawns directives containing <code>iframes</code>. </p> <pre><code>div(ng-repeat='element in elements') ng-switch(on="element.type") a-directive(ng-switch-when="something") another-directive(ng-switch-when="somethingElse") </code></pre> <p>Now, inside the directive I am loading content into the iframe after some event, by doing:</p> <pre><code>$iframe[0].contentWindow.d_contents = "html" $iframe[0].src = 'javascript:window["d_contents"]' </code></pre> <p>Everything works nicely.</p> <p>When I remove one of these elements from the model (in the controller) with something like:</p> <pre><code>elements.remove(object) //using sugarjs, that's not the issue, same behaviour with splice </code></pre> <p>the UI gets updated accordingly, i.e. the element disappear.</p> <p><strong>The problem</strong></p> <p>This works as expected: </p> <pre><code>elements.push(ele1) elements.push(ele2) .. init iframes inside ele1 and ele2 with content .. elements.remove(ele2) </code></pre> <p>Result: <code>ele2</code> disappears from UI, <code>ele1</code> still there with iframe loaded</p> <p>This does not:</p> <pre><code>elements.push(ele1) elements.push(ele2) .. init iframes inside ele1 and ele2 with content .. elements.remove(ele1) </code></pre> <p>Result: <code>ele1</code> disappears from UI, <code>ele2</code> still there with iframe, but iframe content is back to empty, and <code>iframe.load()</code> gets fired. </p> <p>What is happening here? Why is my iframe getting reseted? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload