Meine Anweisung erhält keine Daten. In der Konsole bekomme ich die gesamten Items: undefiniert. Es ist egal, auch wenn ich eine Nummer oder einen Wert von meinem Controller übergebe. Ich bekomme auch keine Werte bei meiner Vorlagen-URL. Vielen Dank im Voraus.Direktive in Angular nicht erhalten DATEN
(function(){
'use strict';
angular
.module('adminApp')
.directive('pagination', paginate);
function paginate() {
return {
restrict: 'A',
scope: {
totalItems: '=',
itemsOnPage: '=',
pageUrl: '=',
currentPage: '='
},
templateUrl: 'assets/js/admin/templates/pagination-template.html',
link: function(scope, element, attrs){
console.log("Total Items: ",scope.totalItems);
},
};
}
})();
HTML:
<div ng-if="vm.promiseReady">
<div pagination totalItems="300" pageUrl="vm.pageUrl" currentPage="vm.currentPage"></div>
</div>
HTML-Vorlage:
<div class="pagination">
<div class="pagination-bttns">
<a class="pagination-bttn"
href="#"
ng-if="currentPage != 1"
ng-href="{{pageUrl}}{{currentPage-1}}"
>
PREVIOUS {{totalItems}}
</a>
<a class="pagination-bttn"
href="#"
ng-if="currentPage != totalItems"
ng-href="{{pageUrl}}/{{currentPage+1}}"
>
NEXT
</a>
</div>
Vielen Dank. Das hat das Problem für mich gelöst. – Nemanja
@Nemanja swapping zu strich-limited fix es? Wenn ja, kann ich den zweiten Vorschlag entfernen. –
Ja, nur der erste Teil hat es für mich getan. Der Wert von 300 läuft noch, obwohl ich das '=' verlassen habe. – Nemanja