Rocco Musolino Rocco Musolino - 1 year ago 124
AngularJS Question

Error: [$injector:unpr] Unknown provider: ngCsvProvider <- ngCsv <- dynamicDemoController

Here is my scenario:

  • file A.js that define the main module.

  • file B.js lazy-loaded (after angular bootstrap) that contains a controller and some directives.

file A.js:

var APP = angular.module('app.hello', ['ui.router', 'ngAnimate', 'ngTable', 'ngSanitize', 'ngCsv']);

(function() {

APP.config(function ($controllerProvider, $compileProvider) {
APP.loadController = $controllerProvider.register;
APP.loadDirective = $compileProvider.directive;


file B.js:

(function() {
"use strict";

APP.loadController("dynamicDemoController", dynamicDemoController);
dynamicDemoController.$inject = ["NgTableParams", "ngCsv"]; // <-- err

function dynamicDemoController(NgTableParams, CSV) {
// ...


I'm injecting
flawlessly but I'm not being able to "inject" the
module and I'm getting this error in console:

Error: [$injector:unpr] Unknown provider: ngCsvProvider <- ngCsv <-

Any idea what am I possibly missing?

Answer Source

You are trying to inject a module in your controller, that's why its causing error.

  dynamicDemoController.$inject = ["NgTableParams", "ngCsv"]; // <-- err

ngCsv is a module and not a service.

Loading of module's should be limited to angular.module.

var myapp = angular.module('myapp', ['ngCsv'])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download