When ng-if are trigerd?
<p>I am currently working on functionality for buttons that are opening directive in modal windows, and I wanted to created it simple is possible, so i took modal container and flag it with versus directive:</p>

<pre><code>&lt;div ng-if="vm.Modal.Modal1"&gt;
&lt;directive-for-modal-one params="vm.params1"&gt;&lt;directive-for-modal-one&gt;
&lt;/div&gt;
 &lt;div ng-if="vm.Modal.Modal2"&gt;
&lt;directive-for-modal-two params="vm.params2"&gt;&lt;directive-for-modal-two&gt;
&lt;/div&gt;
....
</code></pre>

<p>And in controller there is a function that change activity of all of this modal, vm.Modal.n</p>

<pre><code>function test(name){
        CloseModal();

        vm.Modals[name]= true

    }
function CloseModal() {

        for (var property in vm.Modals) {

            vm.Modals[property]= false;

            }
    }
</code></pre>

<p>And problem is in that if you click to open same modal two time, when even the value for ng-if are false and after that true, modal that is reopen are old one, wasn't destroyed. I understand that this is happening because javascript is single thread and that while it is function it will not close, how can I make angular check when this value is changed while I am still inside a function. some kinde refresh or chack command?</p>