I need to run a directive that runs a jPager jquery plugin after an http call has loaded the
The jquery is working fine, but I cannot get the directive to run after the screen is rendered (it just runs before and therefore the scope is empty)
I have tried using $emit and $broadcast demo's but still cant get it to fire.
The scope loads
<div wss-pager class="holder"></div>
<ul id="itemContainer" ng-bind-html="ctData"></ul>
////
function loadData() {
$http({
method: 'GET',
url: 'api/getMyData',
}).
success(function(data, status, headers, config) {
// deferred.resolve(data);
$scope.ctData = data.m_StringValue;
//
$scope.$emit('UpdateJPages');
}).
error(function(data, status, headers, config) {
alert("error" + data);
$scope.ctData= "";
});
};
/////////
angular.module('app').directive("wssPager", [function () {
return {
restrict: "A",
link: function (scope, elem, attrs) {
scope.$on('UpdateJPages', function() {
$("div.holder").jPages({
containerID: "itemContainer",
perPage: 5,
startPage: 1,
startRange: 1,
midRange: 5,
endRange: 1
});
});