I have this directive:
hpDsat.directive('ngElementReady', [function() { return { restrict: "A", link: function($scope, $element, $attributes) { // put watches here. console.log(" WHAT THE @#%*%$??? "); $scope.$eval($attributes.ngElementReady); } }; }]); I never see the output of the console.log. I'm declaring an element like this:
<div data-ng-element-ready="console.log(' ------------------------------- COMPILED! ')" data-ng-if="analysis.type" data-ng-show="showBasicHtml" data-ng-include="analysis.type+'Content.html'"></div> Yes, I am declaring the directive before I declare the controller under which the div element exists. The element appears, ngShow and ngInclude works, and anything in the loaded template works just fine too (more directives, controllers, {{expressions}}, etc).
If I execute it with a compile function, the compile function does work, but still not the link function:
hpDsat.directive('ngElementReady', [function() { return { restrict: "A", compile: function($element, $attributes) { console.log("This I do see."); // THIS WORKS!! return function($scope) { // put watches here. console.log("But not this. Why???"); // DOESN'T WORK!! $scope.$eval($attributes.ngElementReady); }; } }; }]); The console.log of the compile function works fine, but the returned link function still never gets executed.
Any idea why the link function might not get fired?