基本上标题是......
<td data-ng-repeat="j in [0,1,2,3,4,5,6,7,8,9,10]">
Height:{{this.height}}, Width:{{this.width}}
</td>
但是this
引用了$ scope而不是<td>
本身。
答案 0 :(得分:1)
尝试指令方法,也许是这样的?将html更改为
<td data-ng-repeat="j in [0,1,2,3,4,5,6,7,8,9,10]" dimensions>
Height:{{height}}, Width:{{width}}
</td>
.directive('dimensions', function() {
return {
link: function(scope, elem) {
scope.height = elem[0].offsetHeight;
scope.width = elem[0].offsetWidth;
}
}
});