84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
我想打算用 offsetHeight 获取图片的高度 。angular.element(img).ready 这个是dom树加载完就立即执行了。此时图片还没显示出来;所以offsetHeight 获取的高度是0.
想用onload 但是在controller 里面好像是无效的。
小伙看你根骨奇佳,潜力无限,来学PHP伐。
要引入angular版的jquery 叫jqLite
angular.element('#img').height();或者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'); } }; }) ;
要引入angular版的jquery 叫jqLite
angular.element('#img').height();
或者
angular.element(document.querySelector('#img'))[0].offsetHeight