title: Passing value of a variable to angularjs directive template function
body: <p>I am trying to pass a $scope's variable to a directive, but its not working. I am catching the variable in the template function:</p>
  
  <pre><code>app.directive('customdir', function () {
  
      return {
          restrict: 'E',
  
          template: function(element, attrs) {
              console.log(attrs.filterby);
              switch (attrs.filterby) {
                  case 'World':
                      return '&lt;input type="checkbox"&gt;';
              }
              return '&lt;input type="text" /&gt;';
          }
      };
  });
  </code></pre>
  
  <p>What I need is the value of variable <code>filterby</code> not the variable name itself. </p>
  
  <p><a href="http://plnkr.co/edit/OQqLeUIoFNhkqSoeIdyM?p=preview" rel="noreferrer">Plunkr Demo</a> </p>