Reputation: 1873
I have the following row:
<tr ng-click="show()" ng-repeat="lim in limit">
I need to get the offset (i will need Top and Left in px) of this tr.
Is there a way to get the offset in the controller? (either by passing some sort of parameter to function show() or any different way ).
So far I tried passing $event in show($event) and getting $event.pageX and $event.pageY but that is not what I need, i need the offset of the element itself.
Upvotes: 0
Views: 242
Reputation: 4505
You can get the element of the click event in this case the td from the $event.target property so I would pass in $event and then get the offset from this:
$scope.show = function(e){
var offset = e.target.getBoundingClientRect();
console.log(offset);
}
Upvotes: 1