bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

angular-bootstrap: undefined is not a function, [$compile:nonassign] Expression 'undefined' used with directive 'pagination' is non-assignable!

Open predorock opened this issue 12 years ago • 8 comments

Hi everybody, i am trying to include angular-bootstrap pagination in my project. Here i have the error that i cannot fix. Can you please help me about it? image

angular.module('marco',[
    'ngRoute',
    'ui.bootstrap',
    'ui.bootstrap.tpls'
]);

angular.module('marco').controller("PaginationController",function($scope){

  $scope.totalItems = 10;
  $scope.currentPage = 1;

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

  $scope.pageChanged = function() {
    console.log('Page changed to: ' + $scope.currentPage);
  };

  $scope.maxSize = 5;
  $scope.bigTotalItems = 175;
  $scope.bigCurrentPage = 1;
});
<html ng-app="marco">
    <head>
        <title>Test</title>
        <script src="bower_components/jquery/dist/jquery.min.js"></script>
        <script src="bower_components/angular/angular.js"></script>
        <script src="bower_components/angular-route/angular-route.js"></script>
        <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
        <script src="app.js"></script>
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="css/bootstrap-3.1.1-dist/css/bootstrap.css">
    </head>
    <body ng-controller = "PaginationController">
        <center>
                <h4>Default</h4>
                <pagination total-items="totalItems" ng-model="currentPage" ng-change="pageChanged()"></pagination>
        </center>
    </body>
</html>

predorock avatar May 08 '14 12:05 predorock

@predorock not sure what is going on, so could you please provide a minimal reproduce scenario using http://plnkr.co/? One thing that looks strange are dependencies of your module, you shouldn't need to specify 2 modules from the angular-ui/bootstrap as a dependency, this should suffice:

angular.module('marco',[
    'ngRoute',
    'ui.bootstrap'
]);

as described here: https://github.com/angular-ui/bootstrap#installation

As a side note: I hope you know that you don't need jQuery to use directives from this repository.

In any case, please provide a minimal reproduce scenario using http://plnkr.co/, otherwise it is not actionable.

pkozlowski-opensource avatar May 08 '14 15:05 pkozlowski-opensource

I also have this nonassign issue, and my code looks pretty much like the one predorock links to.

UPDATE: I got it working. I had 0.10.0 installed, as I installed it using NuGet - which is apparently behind. I manually upgraded to 0.11.0 and my issued had resolved.

NikolajDL avatar May 09 '14 01:05 NikolajDL

Yes, thanks @Excolo. I have updated it using bower to 0.11.0. Now it works.

predorock avatar May 09 '14 07:05 predorock

I'm already in 0.11.0, still have this problem. very disturbing .....

ghost avatar Aug 01 '14 15:08 ghost

I just tracked down a similar bug in my own project and I discovered I already had my own 'PaginationController'. As the requirements for the pager/pagination directive are looked up, constructed and injected it looked to be constructing 'my' controller instead of the identically named PaginationController in the angular-ui-bootstrap code. Renaming my controller fixed my problem.

awk avatar Aug 28 '14 15:08 awk

I ran into this same issue. I had named a controller PaginationController to test out pagination and didn't realize that it would conflict. I renamed my contorller to PaginationExperimentController and everything started working.

andyfleming avatar Nov 20 '14 00:11 andyfleming

@andyfleming Sad, I don't understand why they simply don't prefix their ui stuff with "ui-" or "ngui-" or something like that. See this comment as well https://github.com/angular-ui/bootstrap/issues/2930#issuecomment-61888767

burzum avatar Dec 02 '14 10:12 burzum

Silly problem. Took me a good 3 minutes and some source diving before realizing my mistake.

JonathanSeguin avatar Feb 04 '15 19:02 JonathanSeguin