Calling a controller inside a factory method
<p>Currently I have a factory method like this:</p>

<pre><code>            open_model: function(som_id){
                var modelSettings = $aside({
                    controller: // a very big controller code
                    size: 'sm',
                    placement: 'right',
                    templateUrl: 'views/id/modal.html',
                    resolve: {
                        modal_data: function(){
                            return area_id;
                        }
                    }
                });
            },
</code></pre>

<p>I want to separate out the controller from this method and call it by name. Currently this is >100 lines of code in controller section and hence it makes factory dirty. So is there a way to define the controller somewhere else, and call the controller by name instead of writing the code. </p>