Tag Archives: AngularJS

AngularJS: Error reports on $injector:modulerr

The most common problem Angular JS has is that an application has failed to launch with an error of $Injector: Modulerr
The error was caused by a failure to load the corresponding Module, but it was difficult to find the Module that needed to be modified.
A simple trick is not to use Angular.min.js, but to use Angular.js. At this point, AngularJS gives detailed error information, which is very helpful in troubleshooting errors.
This is the error I see when I use Angular.js, so I simply remove the $translateProvider issue.
angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module acTodoApp due to:
Error: [$injector:unpr] Unknown provider: $translateProvider
http://errors.angularjs.org/1.5.5/$injector/unpr?24 translateprovider p0 = %

at http://localhost:1337/node_modules/angular/angular.js:68:12 at http://localhost:1337/node_modules/angular/angular.js:4458:19
It’s for the record.
Alva Chien,
2016.5.2

[$ injector:unpr ] Unknown provider:–angular.module () function solution

This is undoubtedly one of the trickiest issues to encounter when developing a project with AngularJS:

ionic.bundle.js:26799 Error: [$injector:unpr] Unknown provider: fifoServiceProvider <- fifoService <- FifoController
http://errors.angularjs.org/1.5.3/$injector/unpr?p0=fifoServiceProvider%20%3C-%20fifoService%20%3C-%20FifoController
    at ionic.bundle.js:13443
    at ionic.bundle.js:17793
    at Object.getService [as get] (ionic.bundle.js:17946)
    at ionic.bundle.js:17798
    at getService (ionic.bundle.js:17946)
    at injectionArgs (ionic.bundle.js:17970)
    at Object.instantiate (ionic.bundle.js:18012)
    at $controller (ionic.bundle.js:23417)
    at Object.self.appendViewElement (ionic.bundle.js:59908)
    at Object.render (ionic.bundle.js:57901)

Encounter this problem, have no hint at all, look for a problem all have no way to start, headache unceasingly.
before we talk about the solution, let’s look at the angular.module function:

angular.module('MyApp',[])

In a SPA project, we can actually add more than one module. The module’s dependencies are then declared in that bracket.
This type of dependent function is called a module declaration.

angular.module('MyServices',['OtherService'])

He also USES it in another way, without the parenthesis:

angular.module('MyServices')

This method without brackets is used to refer to the module. So, the same module, of course, we only need to declare once OK:

angular.module('MyApp',['MyControllers','MyServices','MyDirectives']);

angular.module('MyControllers',[]);
angular.module('MyServices',[]);
angular.momdule('MyDirectives'[]);

So, angular.module(“,[]) is used to declare a module, equivalent to the setter function of an Angular module. Angular.module (), which refers to a module, on which we can add our own definitions.
So I check the code. Almost every service has an Angular. Module (“,[] “) in it. This is used to declare modules. Specially here to write, record down, hope to have encountered the same problem can adopt, this pit is really deep…