我需要在 http 调用加载后运行一个运行 jPager jquery 插件的指令
jquery 工作正常,但我无法在屏幕渲染后运行指令(它只是在之前运行,因此范围为空)
我尝试过使用 $emit 和 $broadcast 演示,但仍然无法启动它。
范围加载
<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
});
});