0

このエラーを含むスタックオーバーフローに関する投稿がたくさんあります。

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 を $inject したい方法と関係があります。

編集: @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?

私はあなたがまだこのすべてのエラーについて私を助けたいと思っていることを願っています:-(

4

1 に答える 1

0

モジュールに ngTable を注入する必要があります。

export default angular.module(name, [
'angularMeteor',
'angularCharts',
'uiRouter',
'ngTable'
])
于 2016-11-13T12:17:28.890 に答える