I want to access height and width property of current html img element to apply ngClass dynamically based on property.
I have this code for html
<div class="cfg-pg-outer-box" ng-repeat="album in album_list">
<div class="cfg-pg-photo-box">
<img ng-src="{{album.thumbnail.image_path}}" ng-class="myclass(this)">
</div>
</div>
I am using AngularJS to apply ngClass dynamically
$scope.myclass = function(element) {
return (element.width > element.height ? 'landscape' : 'portrait');
}
I am not able to read width and height properties. Do you have any suggestion?
album.thumbnailobject have this information maybe like height/width? Do you really need to read it from image object?element.offsetWidth/element.offsetHeight