Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: [$injector:unpr] Unknown provider: ngTableParamsProvider <- ngTableParams

I am trying to use ng-table and tried adding it on many places but its giving error for all cases.

When I am adding ngTable in app.js, its giving:

Error: [$injector:unpr] Unknown provider: ngTableParamsProvider <- ngTableParams

When I am adding ngTable in controller, its giving undefined is not a function for controller.

How should I resolve it?

like image 622
Prateek Avatar asked Jul 10 '14 12:07

Prateek


4 Answers

Another cause of this error is renaming of ngTableParams into NgTableParams in version 1.0.0. So, if you are using version 1.0.0, the code should look like this:

customModule.factory("customTable", function (NgTableParams) {

    function setupNgTable() {
        var parameters = {
            count: 10
        };

        var settings = {
            getData: function (params) {

            }
        };

        return new NgTableParams(parameters, settings);
    }
}
like image 103
Alexei - check Codidact Avatar answered Nov 14 '22 15:11

Alexei - check Codidact


You need

  1. Add reference to <script src="....ng-table.js"></script> (more likely in in your index.html file)
  2. Inject ngTable to your angular module ie:

    var myApp = angular.module('myApp',['ngTable']);

  3. in controller

    myApp.controller('someCtrl', function($scope, ngTableParams) {....});

like image 34
sylwester Avatar answered Nov 14 '22 14:11

sylwester


It looks like ngTableParams has been now changed to NgTableParams, starting with "N" instead of 'n'.

So, now the code will look something like this...

First, Add ng-table.js or ng-table.min.js link in your HTML code.

Then in your app.js or in the script part do like this...

var app = angular.module('XXX', ['ngTable']);

app.controller('XXXXX', function($scope, NgTableParams){

//-Inside wherever your using ngTableParams change it to NgTableParams

................

});

Hope this will help.

like image 12
Sourav Sinha Avatar answered Nov 14 '22 15:11

Sourav Sinha


In order to use ngTable module you need to follow the steps in http://ng-table.com

Mind that NgTableParams injection is with capital N

like image 4
Thiago Bonfim Avatar answered Nov 14 '22 14:11

Thiago Bonfim