angularjs - Get div height from directive $watch function while div is rendering -


i new angular , trying write error_div directive user registration error_div shows listed errors if username/password not valid.

here directive:

    angular.module(app_name).directive('errordiv', function($timeout) {         return {           template: '<li data-ng-repeat="error in login_errors">' +                         '{{error}}' +                     '</li>',            link: function(scope,element,attrs) {               scope.$watch('login_errors', function() {                   console.log(document.getelementbyid('error_div_login').offsetheight);               }, true);           }        };     }); 

here html

<div id="error_div_login" error-div></div> 

the problem if there 3 errors generates 3 list elements increases div height 56px, the

console.log(document.getelementbyid('error_div_login').offsetheight); 

will return 42 height of first 2 list elements.

to 56, need put console.log in $timeout ,like

$timeout(function() {     console.log(document.getelementbyid('error_div_login').offsetheight); }, 100); 

my guess console.log executed while angular rendering div, there more proper way around?

in fact, purpose div height when div content changes , gui staff.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -