title: AngularJS: Create new scope variable name using a variable value
body: <p>I would like to create a new scope variable using the value of a variable passed to a directive's attribute. Just as an example, say we have a simple directive like this:</p>
  
  <pre><code>&lt;div testme field="fieldval"&gt;&lt;/div&gt;
  
  .directive("testme", function () {
      return {
          template: "&lt;div id='testme'&gt;&lt;/div&gt;",
          link: function (scope,elem, attrs){
              $("#testme").html("Hello "+attrs.field);
          }
      }
  })
  </code></pre>
  
  <p>The output is of course the value of the 'field' attribute: </p>
  
  <p>Hello fieldval</p>
  
  <p>However, what I want to do is create a new scope variable called $scope.fieldval, where fieldval is actually the value passed into the attribute 'field'</p>
  
  <p>Any ideas?</p>