title: How to call a directive inside a service in template attribute in AngularJS?
body: <p><strong>Below is the directive code and service code. How to call a directive inside the service.And how to call dynamic templates</strong> </p>
  
  <p>Directive Code</p>
  
  <pre><code>angular.module('TestModule').directive('mymodalwindow', function () {
      return {        
          restrict: 'E',       
  
          template: '&lt;div class="modal-header"&gt;' +
      '&lt;h3&gt;{{modalOptions.headerText}}&lt;/h3&gt;' +
  '&lt;/div&gt;' +       
      };
  });
  </code></pre>
  
  <p>Service Code</p>
  
  <pre><code>angular.module('TestModule').service('modalService', ['$modal',
      function ($modal) {
          var modalDefaults = {
              backdrop: true,
              keyboard: true,
              modalFade: true,
              template://How to call the above define directive here?? 1 way is &lt;mymodalwindow&gt;&lt;/mymodalwindow&gt; But how to pass the directives instead of giving fixed directive name
  
          };}
          ]);
  </code></pre>