我在stackoverflow上看到很多关于此错误的帖子:
Error: [$injector:unpr] Unknown provider: NgTableParamsProvider <- NgTableParams
http://errors.angularjs.org/1.5.8/$injector/unpr?p0=NgTableParamsProvider%20%3C-%20NgTableParams
at http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:33767:12
at http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:38210:19
at Object.getService [as get] (http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:38363:39)
at http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:38215:45
at getService (http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:38363:39)
at injectionArgs (http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:38387:58)
at Object.invoke (http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:38409:18)
at $controllerInit (http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:44053:34)
at nodeLinkFn (http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:42962:34)
at compositeLinkFn (http://localhost:3000/packages/modules.js?hash=5b256037162d84065d102fdba9b374faa45dbd89:42319:13) <div ui-view="" class="ng-scope" data-ng-animate="1">
它们中的大多数似乎与 N gTableParams的第一个大写相关。好吧,我照顾好了。但它不起作用:-(。我从这里开始定位ngTable的例子:https://github.com/esvit/ng-table/tree/master/demo-apps/es6-webpack
这是我的代码:
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import uiRouter from 'angular-ui-router';
import template from './view1.html';
import angularCharts from 'angular-chart.js';
import ngTable from 'ng-table';
const name = 'view1';
class View1 {
constructor($interval, $scope, $reactive, NgTableParams) {
'ngInject';
//some code skipped
var data = [
{ name: "Moroni", age: 50 },
{ name: "Tiancum", age: 43 },
{ name: "Jacob", age: 27 },
{ name: "Nephi", age: 29 },
{ name: "Enos", age: 34 },
{ name: "Tiancum", age: 43 },
{ name: "Jacob", age: 27 },
{ name: "Nephi", age: 29 },
{ name: "Enos", age: 34 },
{ name: "Tiancum", age: 43 },
{ name: "Jacob", age: 27 },
{ name: "Nephi", age: 29 },
{ name: "Enos", age: 34 },
{ name: "Tiancum", age: 43 },
{ name: "Jacob", age: 27 },
{ name: "Nephi", age: 29 },
{ name: "Enos", age: 34 }
];
this.tableParams = new NgTableParams({}, {
dataset: data
});
....
}
View1.$inject = ['NgTableParams'];
export default angular.module(name, [
angularMeteor,
angularCharts,
uiRouter,
]).component(name, {
ngTable,
template,
controllerAs: name,
controller: View1
})
.config(config);
function config($stateProvider) {
'ngInject';
$stateProvider
.state('view1', {
url: '/Allgemein',
template: '<view1></view1>'
});
}
我该如何解决这个错误?也许它与我想要注入NgTableParams的方式有关。
编辑:更新我的代码后像@Sajeetharan说的,我收到了这个错误:
[$injector:modulerr] Failed to instantiate module main due to:
Error: [$injector:modulerr] Failed to instantiate module view1 due to:
Error: [$injector:modulerr] Failed to instantiate module {"ngTable":{"_invokeQueue":[],"_configBlocks":[],"_runBlocks":[],"requires":["ngTable-core","ngTable-browser"],"name":"ngTable"},"default":{"_invokeQueue":[["$provide","provider",{"0":"ngTableDefaultGetData"}],["$provide","value",{"0":"ngTableDefaults","1":{"params":{},"settings":{}}}],["$provide","factory",{"0":"NgTableParams"}],["$provide","factory",{"0":"ngTableEventsChannel"}]],"_configBlocks":[],"_runBlocks":[],"requires":[],"name":"ngTable-core"}} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object
这个错误与我有关吗?我看起来里面的模块现在有一个错误:D。
EDIT2:
在所有模块中添加引号后,例如在您的(@Sajeetharan)示例中:
[$injector:modulerr] Failed to instantiate module main due to:
Error: [$injector:modulerr] Failed to instantiate module view1 due to:
Error: [$injector:modulerr] Failed to instantiate module angularMeteor due to:
Error: [$injector:nomod] Module 'angularMeteor' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.8/$injector/nomod?p0=angularMeteor
他再也找不到角度流星了?! 我从除ngTables之外的所有模块中删除了引号。然后我收到了这个错误:
TypeError: $reactive is not a function
at new View1 (http://localhost:3000/app/app.js?hash=cbd80421227e67667ccffb8b9f1fa2dd725c17fc:272:9)
at Object.invoke (http://localhost:3000/packages/modules.js?
我使用帮助器来获取某些数据。我用$ reactive:$reactive(this).attach($scope);
执行此操作。
为了测试,我删除了$ reactive。但他告诉我,Ngtableparams不是一个构造函数-.-:
TypeError: NgTableParams is not a constructor
at new View1 (http://localhost:3000/app/app.js?hash=24ffbded787373a46d708b60a31466c47e1b756d:404:28)
at Object.invoke (http://localhost:3000/packages/modules.js?
我希望你仍然想帮助我解决所有这些错误: - (
答案 0 :(得分:0)
您需要将ngTable注入模块,
export default angular.module(name, [
'angularMeteor',
'angularCharts',
'uiRouter',
'ngTable'
])