I am running in to some issues with angular where i cant seem to get my head around. I am writing a directive which will check if the scroll position of the window passes the end of an DOM element.
I am using ng-repeat within this element to parse my data. The issue i am having now is that the first time my directive runs the height of the element is not correct yet because my data is not yet parsed.
Is there any way to excecute my directive once the containing data has been loaded? I can get around it with dirty hacks, but ideally i wish this all to be in 1 single directive as it will be used multiple times.
Here's the example code:
<div scrollspy>
<a href="#" ng-repeat="item in items"></a>
</div>
angular.module('module').directive('scrollspy', ['$window', function ($window) {
return function (scope, element) {
// element height here is only 30 because our data is not loaded yet.
// I whish to execute this code when all items are parsed in the DOM
}
}])
Thank you all for your time!