title: Angularjs inject a service into a directive
body: <p>I need to inject a service into a directive. here is what I currently have. I am injecting <code>configFactory</code> into the directive</p>
  
  <pre><code>app.directive('googleAnalytics', function(configFactory){ 
    return {
      restrict: 'E',
      replace: true,
      link : function(scope,element,attrs){
        scope.configs = configFactory.getconfigs();
        console.log(scope.configs);
      },
      template: function(elem, attr){
        return "&lt;script&gt;(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', '', 'auto');&lt;/script&gt;"
      }
    }
  })
  </code></pre>
  
  <p>Here is what my console.log looks like</p>
  
  <pre><code>Promise {$$state: Object}
    $$state:Object
      status:1
      value:Array[1]
        0:Object
          a1:"Survivor"
          a2:"Patient"
          button_name:"DONATE TODAY"
          company_clr_1:"#46b8da"
          ga_id:"UA-XXXXXXXX-1"
  </code></pre>
  
  <p>How do I get <code>ga_id</code>? I need to insert its value here: <code>ga('create', 'ga_id', 'auto')</code></p>
  
  <p>here is what the Service looks like:</p>
  
  <pre><code>app.factory('configFactory', function($rootScope, $log, $q, $http, Data) {
      var configs= {};
          configs.getconfigs=function(){
              var deferred = $q.defer();
  
              Data.get('config').then(function(data){
                  deferred.resolve(data.data);
              });
                  return deferred.promise;
          } 
      return configs;
  });
  </code></pre>