-
-
Save shlomitc/c60382bb8da3426444ad8496e049de28 to your computer and use it in GitHub Desktop.
Angular Directive Compilation Order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body ng-app="myApp"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script> | |
<parent> | |
<child></child> | |
</parent> | |
<script id="jsbin-javascript"> | |
angular.module('myApp', []) | |
.directive('parent', function(){ | |
return { | |
restrict: 'E', | |
controller: function(){ | |
console.log(3); | |
}, | |
compile: function() { | |
console.log(1); | |
return function() { | |
console.log(6); | |
} | |
} | |
}; | |
}) | |
.directive('child', function(){ | |
return { | |
restrict: 'E', | |
controller: function(){ | |
console.log(4); | |
}, | |
compile: function() { | |
console.log(2); | |
return function() { | |
console.log(5); | |
} | |
} | |
}; | |
}) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">angular.module('myApp', []) | |
.directive('parent', function(){ | |
return { | |
restrict: 'E', | |
controller: function(){ | |
console.log(3); | |
}, | |
compile: function() { | |
console.log(1); | |
return function() { | |
console.log(6); | |
} | |
} | |
}; | |
}) | |
.directive('child', function(){ | |
return { | |
restrict: 'E', | |
controller: function(){ | |
console.log(4); | |
}, | |
compile: function() { | |
console.log(2); | |
return function() { | |
console.log(5); | |
} | |
} | |
}; | |
})</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myApp', []) | |
.directive('parent', function(){ | |
return { | |
restrict: 'E', | |
controller: function(){ | |
console.log(3); | |
}, | |
compile: function() { | |
console.log(1); | |
return function() { | |
console.log(6); | |
} | |
} | |
}; | |
}) | |
.directive('child', function(){ | |
return { | |
restrict: 'E', | |
controller: function(){ | |
console.log(4); | |
}, | |
compile: function() { | |
console.log(2); | |
return function() { | |
console.log(5); | |
} | |
} | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment