2014-03-25 66 views
0

我無法爲我的應用程序設置Angular/bootstrap如何在我的情況下設置Angular/Bootstrap UI?

我正在關注此頁面的分頁介紹。

http://angular-ui.github.io/bootstrap/

我app.js

angular.module('myApp', ['ngRoute','ui.bootstrap']). 
    config(['$routeProvider', function($routeProvider) { 
     …. 
}]); 

controller.js

angular.module('myApp', ['ngRoute']). 
controller('PaginationCtrl',['$scope', function ($scope) { 
    $scope.totalItems = 64; 
    $scope.currentPage = 4; 
    $scope.maxSize = 5; 

    $scope.setPage = function (pageNo) { 
    $scope.currentPage = pageNo; 
    }; 

    $scope.bigTotalItems = 175; 
    $scope.bigCurrentPage = 1; 
}]) 

HTML

<div id='pagination-wrapper' ng-controller='PaginationCtrl'> 

<pagination direction-links="false" total-items="totalItems" page="currentPage" num-pages="smallnumPages"></pagination> 

</div> 

我沒有錯誤,當我加載頁面,但我可以似乎看不到t他的分頁功能。任何人都可以幫助我嗎?非常感謝!

+0

您是否嘗試過包括在controller.js依賴 'ui.bootstrap'? – BlakePetersen

+0

如果我這樣做,我得到了依賴注入錯誤... – Links

回答

2

看起來問題在於在那裏重新聲明瞭依賴關係。如果您從controller.js模塊中刪除了ngRoute依賴項,它將起作用。您也可以放棄您不使用的示例變量。

angular.module('myApp'). 
    controller('PaginationCtrl',['$scope', function ($scope) { 
     $scope.totalItems = 64; 
     $scope.currentPage = 4; 
}]); 

對於工作示例:http://plnkr.co/edit/wpgoDrA2Z7pjXbgdNrM8?p=preview

相關問題