What if the controller in angularjs cannot get the height of the picture?

  node.js, question

I want to use offsetHeight to get the height of the picture.
This is the dom tree and will be executed as soon as it is loaded. At this time, the picture has not yet been displayed. So offsetHeight gets a height of 0.

I want to use onload, but it seems invalid in the controller.

The jquery to introduce the angular version is called jqLite.

angular.element(‘#img’).height();
Or ..
angular.element(document.querySelector(‘#img’))[0].offsetHeight

<body ng-app="myModule">
 <h1 my-directive>Hello Plunker!  width: {{width}}, height: {{height}}
 </h1>
 </body>
 
 
 angular.module('myModule', [])
 .directive('myDirective', function($timeout) {
 return {
 restrict: 'A',
 link: function(scope, element) {
 scope.height = element.prop('offsetHeight');
 scope.width = element.prop('offsetWidth');
 bracket
 };
 })
 ;