JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>
<div ng-controller="Ctrl">
{{tests.compiled}}
<hr />
{{tests.linked}}
<div ng-if="false">
<div test></div>
</div>
</div>
JavaScript
console.clear();
angular.module('app', []).directive('test', function($timeout, tests) {
return {
restrict: 'A',
compile: function() {
console.log('compile test');
$timeout(function() {
tests.compiled = 'test directive WAS compiled';
});
return function() {
console.log('link test');
$timeout(function() {
tests.linked = 'test directive WAS linked';
});
}
}
}
});
angular.module('app').factory('tests', function() {
return {
compiled: 'test directive was NOT compiled',
linked: 'test directive was NOT linked'
}
});
function Ctrl($scope, tests) {
$scope.tests = tests;
}