Angular: Empty Fiddle

http://angularjs.org/

by dkrotts

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular.min.js"></script>
<div my-directive my-value="foo">
  Lorem ipsum&hellip;
</div>

JavaScript

function myDirective() {
	
  function compile(cElement, cAttrs) {
  
  	var template = '<div>My Value: {{vm.myValue}}</div>';
    cElement.append(template);
  
  }
  
  function MyCtrl() {
		
    console.log(this.myValue); // outputs "foo"
    
  }
  
  return {
  	compile: compile,
    controller: MyCtrl,
    controllerAs: 'vm',
    bindToController: true,
    scope: {
    	myValue: '@'
    }
  }
  
}

angular
	.module('myApp',[])
  .directive('myDirective', myDirective);