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?
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);
}
}
You need
<script src="....ng-table.js"></script>
(more likely in in your index.html file)Inject ngTable to your angular module ie:
var myApp = angular.module('myApp',['ngTable']);
in controller
myApp.controller('someCtrl', function($scope, ngTableParams) {....});
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With