title: AngularJs directives - how to get attributes values from within directive
body: <p>Any idea how to access attributes values from inside the directive?</p>
  
  <pre><code>    angular.module('portal.directives', [])
          .directive('languageFlag', ['$routeParams', function(params) {
              return function(scope, element, attrs) {
                  console.log(attrs["data-key"]); // returns undefined
                  console.log(element.attr('data-key')); // returns {{data-key}}
                  angular.element(element).css('border', '1px solid red');
              };
          }]);
  </code></pre>
  
  <p>Html code is:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li ng-repeat="lng in flags"&gt;
          &lt;a class="lngFlag {{flag.Key}}" data-key="{{flag.Key}}" data-id="{{lng.Id}}" ng-click="changeLangHash({'lng':lng.Id })" language-flag&gt;&lt;/a&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Thanks</p>