title: How do you point to an AngularJS Template from within a JS file provided by a Grails plugin?
body: <p>I have a Grails app which pulls in several Grails Plugins. These plugins need to be reused by several other Grails apps not just my own.</p>
  
  <p>In a Resources Bundle in one of the Grails Plugins I have the following defined:
  <em>leaving this for completeness, but I have since switched to the Asset-Pipline</em></p>
  
  <pre><code>modules = {
      directivea {
          resource url: 'directives/directivea/directivea.js'
          resource url: 'services/restapis.js'
      }
  }
  </code></pre>
  
  <p>In a Javascript file in one of the plugins I have the following directive defined:</p>
  
  <pre><code>ModuleA.directive('directivea',function() {
      return {
          restrict: 'EA',
          scope: {
              'objId' : '='
          },
          replace: true,
          link: function(){
              $scope.ObjId = attributes[''];
              $scope.someFunction($scope.ObjId);
          },
          controller: function(){
              $scope.someFunction = function(objId){
                  //some stuff happens here
              };
          },
          templateUrl: 'directives/directivea/directivea.html'
      }
  });
  </code></pre>
  
  <p>It seems to be executing the controller just fine but when it tries to pull in the template it chokes on:</p>
  
  <blockquote>
    <p>GET /appname/directives/directivea/directivea.html
    404 (Not Found)</p>
  </blockquote>
  
  <p>This makes sense because that's not where the partial template will be. Where would it be though? How can I keep that information isolated to within the plugin but usable by all the downstream applications? I'd like to avoid defining in-line templates if I can.</p>
  
  <p><strong>**EDIT TO INCLUDE STRUCTURE**</strong></p>
  
  <p><em>Structure of Plugin:</em></p>
  
  <ul>
  <li>grails-app
  <ul>
  <li>conf
  <ul>
  <li>PluginNameForGrailsResources.groovy</li>
  <li>BuildConfig.groovy</li>
  </ul></li>
  <li>controllers
  <ul>
  <li>PluginControllerA.groovy</li>
  <li>PluginControllerB.groovy</li>
  </ul></li>
  <li>domain
  <ul>
  <li>PluginDomainA.groovy</li>
  </ul></li>
  </ul></li>
  <li>web-app
  <ul>
  <li>css</li>
  <li>directives
  <ul>
  <li>directivea
  <ul>
  <li>directivea.js</li>
  <li>directivea.html</li>
  </ul></li>
  </ul></li>
  <li>services
  <ul>
  <li>restapis.js</li>
  </ul></li>
  </ul></li>
  <li>application.properties</li>
  <li>PluginNameForGrailsGrailsPlugin.groovy</li>
  </ul>
  
  <p><em>Structure of the application referencing my Plugin:</em></p>
  
  <ul>
  <li>grails-app</li>
  <li>conf
  <ul>
  <li>BuildConfig.groovy</li>
  </ul></li>
  <li>controllers</li>
  <li>domain</li>
  <li>views
  <ul>
  <li>layouts
  <ul>
  <li>main.gsp</li>
  </ul></li>
  <li>index.gsp (references to directivea via resources r:require tag)</li>
  </ul></li>
  <li>web-app</li>
  <li>css
  <ul>
  <li>main.css</li>
  </ul></li>
  <li>js
  <ul>
  <li>index.js</li>
  </ul></li>
  <li>application.properties</li>
  </ul>
  
  <p><strong>**EDIT TO INCLUDE STRUCTURE POST-ASSET-PLUGIN-SWITCHOVER**</strong>
  <em>no more Resources defined, BuildConfig.groovy now references the asset pipline instead of Resources, no more files in web-app</em></p>
  
  <ul>
  <li>grails-app
  <ul>
  <li>conf
  <ul>
  <li>BuildConfig.groovy</li>
  </ul></li>
  <li>controllers
  <ul>
  <li>PluginControllerA.groovy</li>
  <li>PluginControllerB.groovy</li>
  </ul></li>
  <li>domain
  <ul>
  <li>PluginDomainA.groovy</li>
  </ul></li>
  <li>assets
  <ul>
  <li>javascripts
  <ul>
  <li>directivea
  <ul>
  <li>directivea.js</li>
  <li>directivea.html</li>
  </ul></li>
  <li>services
  <ul>
  <li>restapis.js</li>
  </ul></li>
  </ul></li>
  <li>application.properties</li>
  <li>PluginNameForGrailsGrailsPlugin.groovy</li>
  </ul></li>
  </ul></li>
  </ul>