0
我有一個分頁鏈接指令,與納克級的角JS指令
app.directive('postsPagination', function(){
return{
restrict: 'E',
template: '<ul class="pagination" ng-show="totalPages > 1">'+
'<li ng-class="disabled: currentPage!=1"><a href="javascript:void(0)" ng-click="getPosts(1)">«</a></li>'+
'<li><a href="javascript:void(0)" ng-click="getPosts(currentPage-1)">‹ Prev</a></li>'+
'<li ng-repeat="i in range" ng-class="{active : currentPage == i}">'+
'<a href="javascript:void(0)" ng-click="getPosts(i)">{{i}}</a>'+
'</li>'+
'<li ng-show="currentPage != totalPages"><a href="javascript:void(0)" ng-click="getPosts(currentPage+1)">Next ›</a></li>'+
'<li ng-show="currentPage != totalPages"><a href="javascript:void(0)" ng-click="getPosts(totalPages)">»</a></li>'+
'</ul>'
};
});
納克級不工作時,當前頁面的值不equel爲1
<li ng-class="disabled: currentPage!=1"><a href="javascript:void(0)" ng-click="getPosts(1)">«</a></li>'+
這是錯誤。
我怎樣才能解決這個問題呢?
是你的類的名稱被禁止?你想達到什麼目的? – Doruk
if currentPage!= 1,我想添加名爲「disabled」的類 – Jishad
嘗試在'{}'中包裝代碼,就像'ng-class =「{disabled:currentPage!= 1}」 – Doruk