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

4

15

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?

Diathesis answered 10/7, 2014 at 12:1 Comment(1)
Can you create a plunker? My guess though is that you are not injecting ngTable into your module like this bazalt-cms.com/ng-table/example/1.Intrigue
P
15

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) {....});

Politics answered 10/7, 2014 at 13:45 Comment(5)
I did the same but then it was giving undefined is not a function for controller.Diathesis
can you post your controller code or create plnkr ?Politics
did this also but still the same error undefined is not a function for controller. I am creating plnkr. Will post soonDiathesis
Hi 99% step 2. please double check I've just get error like you when I removed ngTable from arrayPolitics
Thanks @Politics . Actually I was using multiple controllers and in all, I was using angular.module('myApp',['ngTable']).controller('ctrl',...) So later on defining angular app in parent like you said in 2nd step worked to resolve problem.Diathesis
F
23

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);
    }
}
Forayer answered 18/6, 2016 at 6:5 Comment(0)
P
15

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) {....});

Politics answered 10/7, 2014 at 13:45 Comment(5)
I did the same but then it was giving undefined is not a function for controller.Diathesis
can you post your controller code or create plnkr ?Politics
did this also but still the same error undefined is not a function for controller. I am creating plnkr. Will post soonDiathesis
Hi 99% step 2. please double check I've just get error like you when I removed ngTable from arrayPolitics
Thanks @Politics . Actually I was using multiple controllers and in all, I was using angular.module('myApp',['ngTable']).controller('ctrl',...) So later on defining angular app in parent like you said in 2nd step worked to resolve problem.Diathesis
S
12

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.

Shyster answered 20/6, 2016 at 9:46 Comment(2)
To format code indent with 4 spaces to make your answer more readable. ;)Toddle
Thanks @ToddleShyster
L
4

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

Laliberte answered 27/9, 2016 at 14:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.