AngularJS: Невозможно получить значение переменной из области видимости ctrl в директиву
HostingCtrl:
function HostingListCtrl($scope, Hosting) {
Hosting.all().success(function(data) {
$scope.hostings = data;
});
}
HTML-шаблон:
<pagination items-count="{{hostings.length}}" current-page="currentPage" items-per-page="{{itemsPerPage}}"></pagination>
Директива:
admin.directive('pagination', function() {
return {
restrict: 'E',
replace: true,
templateUrl: "<%= asset_path('angular/templates/ui/pagination.html') %>",
scope: {
currentPage: '=',
itemsCount: '@',
itemsPerPage: '@'
},
controller: function($scope, $element, $attrs) {
console.log($scope);
console.log($scope.itemsCount);
},
link: function(scope, element, attrs, controller) {
}
};
});
Я пытаюсь заполучить значение переменной itemsCount в директиве, но когда я пытаюсь его утешить, это значение пустое. Странная вещь в том, что когда console.log весь объем, он там:
Scope {$id: "005", $childTail: null, $childHead: null, $prevSibling: null,
$nextSibling: null…}
$asyncQueue: Array[0]
$childHead: null
$childTail: null
$destroyed: false
$isolateBindings: Object
$listeners: Object
$nextSibling: Child
$phase: null
$prevSibling: null
$watchers: Array[3]
$id: "005"
$parent: Child
$root: Scope
currentPage: 1
itemsCount: "11"
itemsPerPage: "5"
this: Scope
__proto__: Object
Также, когда я проверяю источник HTML
<nav class="pagination" items-count="11" current-page="currentPage" items-per-page="5">