I have created a directive for Google Map and I want it to cover 100% of parent container's width (works) and also 100% of parent container's height (did not work with css height:100%;). But the css is not my problem anymore. So I have created a method
getHeightOfMap(){
if(document.getElementById('mapContainer').offsetHeight<100){
var containerHeight = document.getElementById('map-canvas').parentNode.parentNode.parentNode.offsetHeight;
if(containerHeight<100){
containerHeight = 400;
}
return containerHeight+"px";
}
return document.getElementById('mapContainer').offsetHeight+"px";
}
And here is how I use it in html template
<div id="mapContainer" style="margin:4px 0 -5px 0;" ng-style="{ 'height' : googleMapsCtrl.getHeightOfMap() }">
<div id="map-canvas" style="display:block;height:100%;"></div>
</div>
This works great, but I found out that it use to "refresh" the ng-style
what kills the performance (that's what AngularJS Batarang says) and after some time the app crashes.
Why is it happing ? And what is wrong with my approach in solving the problem with height ?