angularjs how to find img element height and width

Viewed 10335

Hi I'm trying to find an image element's height and width in order to resize it. However everytime I use elem.height() or elem.width() I get 0?

html

<div>
    <img data-ng-src="{{photosrc}}" lightbox-resize-image>
</div>

directive.js

.directive('lightboxResizeImage', function() {
return {
    restrict: 'A',
    link: function(scope, elem, attrs) {

        console.log(elem.parent().width()); //==equals 575
        console.log(elem.width()); //this always equals 0

  }
  });
1 Answers
Related