I need to run a directive that launches the jQuery jPager plugin after the HTTP call has loaded the elements
in the DOM.jquery works fine, but I canβt get the directive to start after the screen is displayed (it starts before and therefore the area is empty)
I tried using demodulation of $ emit and $ broadcast, but still can not start it.
Area loads tags
in itemContainer, then jQuery prints the data.<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) {
$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
});
});
source
share