AngularJS 1.4

by Shreyas Agarkar

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<body ng-app="myApp">
  <my-directive attr='StackOverflow'></my-directive>
</body>

JavaScript

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

app.directive('myDirective', function() {
  return {
    restrict: 'E',
    template: 'I want to print the attribute value: {{attr}}',
    scope: {
      attr: '@attr'
    },
    controller: function($scope){
    	console.log($scope.attr);
    }
  };
});