Currently, I am facing a challenge with the header element in my angular app. It has a dynamic height that is set only once during initialization. Now, my goal is to place another element, let's call it foo, in the scrollable view of the app in such a way that its height matches the screen height MINUS the height of the header. This will ensure that all elements are perfectly fitted onto the screen.
I came across a solution suggesting the use of the following code:
var myHeight = angular.element(document.querySelector('#header'))[0].offsetHeight
After obtaining the height of the header, one can apply this dynamically using inline styling like this:
<foo style="height: calc(100vh - {{myHeight}})">
It's worth mentioning that the 'calc' function used here belongs to CSS.
The question that arises now is - where should this code snippet be applied? When exactly is the right time for me to calculate and assign the correct height to ensure everything works smoothly?