Angular: Empty Fiddle

http://angularjs.org/

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
    <div ng-controller="MyCtrl">
      <button my-directive data-img_id="hello world">My button directive</button>
    </div>

JavaScript

var myApp = angular.module('myApp',[]);

    myApp.controller('MyCtrl', function ($scope) {
        $scope.name = 'Superhero';
    });

    myApp.directive('myDirective', function () {
        return {
          restrict: 'A',
          link: function (scope, element, attrs) {

            element.on('click', function () {
              console.log(attrs.imgId);
            })
          }
        }
    });