title: AngularJS register controller once
body: <p>That's what I'm doing. There is application with pages and different controls that may be put on pages by site admin/editor. All pages share one <code>ng-app</code> defined on master page. All controls are supplied with .js files with angular controllers. Let's suppose that I have an image gallery block:</p>
  
  <pre><code>&lt;div ng-controller='imageGalleryCtrl'&gt;
      do something amazing here
  &lt;/div&gt;
  &lt;script src='imageGallery.js'&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Inside script there is a simple controller registration like:</p>
  
  <pre><code>angular.module('myApp').controller('imageGalleryCtrl', ... );
  </code></pre>
  
  <p>So. If I have 10 image galleries, I'll execute controller registration 10 times. It looks like this will work, but hell - I don't want it to be so =)</p>
  
  <p>For now I just have all controls' scripts registration on a master page, but I don't like it as well, because if there is no image gallery on a page, I don't want it's script be downloaded during page load.</p>
  
  <p>The question is - is there any proper way to understand if controller have been registered in a module already and thus prevent it from re-registering?</p>
  
  <p><strong>---------------</strong></p>
  
  <p>Well, though I've found no perfect solution, I must admit that the whole idea isn't very good and I won't think about it before my site will grow too big to assemble whole angular app on master page.</p>