I am working on a table that is generated using ng-repeat, and I want to ensure that each td
in the tbody
is square. Since all the td
s have an equal width, I only need to adjust the first one. However, the size of the table and td
will change when the window is resized due to the dynamic nature of the page.
I have included a stylesheet in the head
.
<style type="text/css">.squerify>tr{height:60px;}</style>
To change the height dynamically, I am using the following script:
document.styleSheets[1].cssRules[0].style.height=document.querySelector('.squerify td').offsetWidht+"px";
This script works as intended, but I am curious about how to get Angular to notify me when the width of the td
changes (I was considering using the 'onresize'
window event).
While the onresize
event may work for now, I am concerned about the initialization process. I have not yet discovered a way to have Angular notify me when it has completed all its operations.
PS.: The table is visible on the screen, in case that impacts anything.
These are the questions I have:
- Is there a more effective way to monitor page resizes in Angular?
- What is the best approach for the initialization of the table?