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

Prateek picture Prateek · Jul 10, 2014 · Viewed 12.7k times · Source

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?

Answer

Alexei - check Codidact picture Alexei - check Codidact · Jun 18, 2016

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