Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>www.w3docs.com</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <script> angular.module('test',[]) .controller('testCtrl',function($scope){ console.log($scope,'ctrl') }) .directive('myTest',function(){ return { restrict: 'EA', scope: true, compile: function(){ return function(scope){ console.log(scope,'directive'); } } } }) </script> </head> <body> <div ng-app="test"> <div ng-controller="testCtrl"> <div my-test></div> <div my-test></div> <div my-test></div> </div> </div> </body> </html>