Example
So the below template gets loaded as the content for a modal. I can read the scope I've set, but I can't understand how I've not bound the <pagination>
to totalItems
.
Template.html
<div class="modal-header">
<h3 class="modal-title">{{$parent.helpName}}</h3>
</div>
<div class="modal-body">
Page {{currentPage }} of {{totalItems}}
<pagination boundary-links="true" total-items="totalItems" ng-model="currentPage" class="pagination-sm" previous-text="‹" next-text="›" first-text="«" last-text="»"></pagination>
<div data-ng-show="page.pageNumber == currentPage" data-ng-repeat="page in $parent.helpPages">
<ul tabset typeof="pills">
<li tab data-ng-repeat="subPage in page.pills" data-heading="{{subPage.tabTitle}}">
<div class="panel panel-default">
<div class="panel-body" style="overflow:auto;" data-ng-bind-html="subPage.pillDiv">
</div>
</div>
</li>
</ul>
</div>
</div>
Controller.js
app.directive('myDirective', function factory (){
return {
restrict: 'A', // IE8 doesn't support 'custom tags'
template:'<a ng-hide="!overlayName" class="btn btn-primary" ng-click="showHelp(overlayName)">Need Help <i class="fa fa-question-circle"></i></a>',
controller: function overlayCtrl ($scope, $modal, data) {
// [A] overlay control properties
$scope.helpModal = null;
$scope.overlayName = __hasOverlay($scope.$parent.step.shortDesc); // Right now, look up the overlay by the shortDesc
if ($scope.overlayName) $scope.overlayName = $scope.overlayName.help;
// [B] overlay control methods
$scope.showHelp = function (name) {
data.getHelpOverlay(name).then(function (helpContent) {
$scope.helpPages = helpContent;
$scope.helpName = name;
$scope.helpModal = $modal.open({
scope:$scope, controller:function ($scope, $sce) {
// the scope I'd expect <pagination>'s model to bound on
$scope.currentPage = 1;
$scope.totalItems = $scope.$parent.helpPages.length;
// other code...
},
templateUrl:'app/steps/templates/helpOverlay.html',
size:'lg'
});
});
}
}
};
});