title: How to use a scope in Directive template
body: <p>I want to use $scope variable in template function of directive like this.
  In the other words i want to generate directive template inside of directive and by using $scope variable.</p>
  
  <p>Help me to connect template function to controller.</p>
  
  <pre><code>directive("data", ['$compile', '$http', '$templateCache',function ($http,$rootScope) {
      return{
      link: function (scope, elem, attrs, ctrl) {
          scope.template = something // I want Generate template here
      },
      template:function(element , attrs){ 
          return $scope.template // I can't access scope here
      }
  }
  </code></pre>