I have a directive which links to a jquery ticker plugin call. Inside the directive i have some elements repeating for the plugin to cycle through. The data in the elements itself is containing from an ajax request.
Here is the code
myApp.directive('vTicker', ['$timeout', function($timeout) {
return {
link: function($scope, iElm, iAttrs, controller) {
$timeout(function () {
// console.log($(iElm).html());
$(iElm).vTicker($scope.$eval(iAttrs.vTicker));
}, 0);
}
};
}]);
And here is the element
<div id="newsticker" v-ticker="{speed: 400,pause: 6000}">
<ul class="list-unstyled">
<li class="news-item" ng-repeat="newsItem in news">
<a href="http://www.nasdaqdubai.com/trading/disclosure-detail?itemID="{{newsItem.id}} target="_blank">{{newsItem.issuer}} : {{newsItem.headline}}</a>
</li>
</ul>
The problem is when the directive renders, the ng-repeat hasnt completed rendering. $timeout is not helping either as the content is coming from an ajax call in the controller.
Any help? I want the directive to wait rendering until the controller get the data and ng-repeat render the content in the dom.
Thanks.