How does angular "$uibModalInstance.close(data)" works? : <p>The official documentation of AngularJS does not contain any thing that describes how <code>$uibModalInstance.close</code> works, in the following code fragment, <code>scope.close</code> is a method used to close the modal window and pass an object to the caller controller</p>



<pre class="lang-js prettyprint-override"><code>var app = angular.module('myApp');

app.controller('ModalController', ['$uibModalInstance', modalControllerFn]);

function modalControllerFn($uibModalInstance) {
    var scope = this;

    // some data object
    scope.data = {key1: "value1", key2: "value2"};

    scope.close = function() {
        $uibModalInstance.close(scope.data);
    }
}
</code></pre>



<h3>Question (1)</h3>

<p>Does passing anything belonging to the modal scope using <code>$uibModalInstance.close</code> (non-literal value, i.e: <code>scope.x</code>) prevents angular garbage collection from destroying the entire modal scope? is this a scenario for causing memory leaks?</p>

<h3>Question (2)</h3>

<p>How does angular <code>$uibModalInstance.close(data)</code> exactly works?</p>
