Check out the following code snippet for my custom directive:
mymodule.directive("test", function($compile) {
return {
restrict: 'E',
replace: true,
template:
'<div data-date="{{avail}}"></div>',
scope: {
avail: '='
},
controller: function($scope) {
$scope.dump = function(el) {
console.log($('<div>').append(el.clone()).html());
};
},
link: function postLink($scope, $element, $attrs) {
$scope.dump($element); // output '<div data-date="{{avail}}"></div>'
$scope.dump($compile($element)($scope)); // output '<div data-date="{{avail}}"></div>'
setTimeout(function() {
$scope.dump($element); // output '<div data-date="12.10.2014"></div>'
}, 1);
}
}
});
I'm trying to figure out how to fetch the compiled string like this
<div data-date="12.10.2014"></div>
during the execution of the postLink function (without relying on setTimeout).