Currently, I have a package containing multiple js files that were created from typescript files.
However, when I attempt to apply minification to the package, the webpage encounters errors.
The error message displayed on the Chrome console is:
Uncaught Error: [$injector:modulerr] Failed to instantiate module AppModule due to: Error: [$injector:unpr] Unknown provider: n
After conducting some tests, I narrowed down the issue to either the app.module or app.routes files. The snippets of these files are provided below:
Snippet from app.module:
((): void=> {
var app = angular.module("AppModule", ['ngRoute', 'ngMessages', 'app.xxx.xxx.xxxModule', 'ngSanitize']);
app.config(AppModule.Routes.configureRoutes);
})();
Snippet from app.routes:
/// <reference path="../../../../../scripts/typings/angularjs/angular.d.ts" />
/// <reference path="../../../../../scripts/typings/angularjs/angular-route.d.ts" />
module AppModule {
declare var staticsDir: string;
export class Routes {
static $inject = ["$routeProvider"];
static configureRoutes($routeProvider: ng.route.IRouteProvider) {
$routeProvider.when("/xxx", { controller: "Uni.controllers.xxx", templateUrl: staticsDir + "/projects/xxx/xxx/xxx/xxx.html", controllerAs: "xxx" });
$routeProvider.when("/xxx2", { controller: "Uni.controllers.xxx2", templateUrl: staticsDir + "/projects/xxx2/xxx2/xxx2/xxx2.html", controllerAs: "xxx2" });
}
}
}
(Note that the names have been replaced with xxx for privacy reasons.)
It seems that the error pertains to the $routeProvider. Could the issue lie in how I am injecting it? How can I properly inject this to ensure compatibility with minification?