I am trying to set the element's css property top base on it's height. To do it I create a directive like this:
directive('errormsgbox', function($timeout) {
return {
restrict: 'EA',
scope: false,
replace:true,
templateUrl: 'submitter/reports/errormsgbox.html',
link: function(scope,element) {
$timeout(function(){
$timeout(function(){
console.log(element[0].offsetHeight);
},2000);
},2000)
}
};
})
Directive Html:
<span ng-if='expenses.hasBlockers || expenses.hasWarnigs' style='border:1px solid gray' ng-show='policyViolation && showpencil' class='msgbox'>
<ul>
<li ng-repeat='policymsg in expenses.policyMsg'>
<span class='floatleft' ng-class="showPolicyClass(policymsg.type)">{{policymsg.type}} - </span><span style='width:285px;' class='floatleft'>{{policymsg.message}}</span>
<div class='clear'></div>
</li>
</ul>
</span>
Main Html:
<td class="text-center" style='position:relative'>
<errormsgbox></errormsgbox>
</td>// it is in a table cell, the content of directive is from ng-repeat in this table
I need to access <span>.but as you can see, directive works fine it will show the correct info, but every time it will log undefined for element height. any idea How can I access this?