我有两个表(.table1 和 .table2)并排放置在页面上的单独 DIV 中,并且无论内容如何,我都希望第二个表行与第一个表行的高度匹配,以便它们完美对齐。第一个表是使用 ng-repeat 基于数据库中的值构建的,因此高度可以变化 - 无论哪种方式,第二个表中的等效行都应该始终匹配。
我一直在尝试许多不同的想法,但我认为在 ng 样式中为 table2 行使用 jQuery 选择器可能有效(见下文),但它没有;
<tr ng-style="{'height': $('.table1 tr').eq('$index').height()+'px' }"></tr>
或者
<tr ng-style="{'height': $('.table1 tr:nth-child($index).height()+'px' }"><tr>
显然不起作用,但如果我用特定值替换 jQuery 选择器,它会按预期设置行的样式;
<tr ng-style="{'height': 50+'px'}></tr>
我对使用 jQuery 并不在意,而是在其他地方使用它,所以没有问题,但基本上我只想根据第一个表 (.table1) 的行高对齐每个表中行的高度。所以问题是,如何获取 table1 中一行的高度值,并使用角度将其应用为 table2 中同一行的高度?