未知提供者:eProvider <- e
Unknown provider: eProvider <- e
我正在更新旧版 Angular JS 1.7 应用程序并添加一个 AngularJS Material Popup modal。该应用程序在部署到生产环境时使用 Webpack 和压缩(见下文:drop_console
= true)。
Webpack:
new TerserPlugin({
terserOptions: {
compress: {
drop_console: (isProduction) ? true : false, // true
},
},
}),
我知道 Angular 需要引用注入的依赖项,.controller('myCtrl', ['$scope', function($scope) {
,因为缩小会更改依赖项的名称,这可能会导致我得到的错误:
[$injector:unpr] Unknown provider: eProvider <- e ...
但是这个模式的工作方式是通过这样绑定一个控制器函数:
工厂服务:
angular.module('MODULE').factory('myService', ['$mdDialog',
function ($mdDialog) {
return {
...
$mdDialog.show({
controller: DialogController, // bound to dialog controller below
...
});
function DialogController($scope, $mdDialog) { // dependencies injected here
...
当依赖项位于模块内时,如何在依赖项周围提供引号,function DialogController($scope, $mdDialog) {
?
尝试:
$mdDialog.show({
controller: ['$scope', '$mdDialog', DialogController]
...
});
function DialogController($scope, $mdDialog) {/* ...*/}
附带说明,请避免在 services/factories.
中定义对话框
我正在更新旧版 Angular JS 1.7 应用程序并添加一个 AngularJS Material Popup modal。该应用程序在部署到生产环境时使用 Webpack 和压缩(见下文:drop_console
= true)。
Webpack:
new TerserPlugin({
terserOptions: {
compress: {
drop_console: (isProduction) ? true : false, // true
},
},
}),
我知道 Angular 需要引用注入的依赖项,.controller('myCtrl', ['$scope', function($scope) {
,因为缩小会更改依赖项的名称,这可能会导致我得到的错误:
[$injector:unpr] Unknown provider: eProvider <- e ...
但是这个模式的工作方式是通过这样绑定一个控制器函数:
工厂服务:
angular.module('MODULE').factory('myService', ['$mdDialog',
function ($mdDialog) {
return {
...
$mdDialog.show({
controller: DialogController, // bound to dialog controller below
...
});
function DialogController($scope, $mdDialog) { // dependencies injected here
...
当依赖项位于模块内时,如何在依赖项周围提供引号,function DialogController($scope, $mdDialog) {
?
尝试:
$mdDialog.show({
controller: ['$scope', '$mdDialog', DialogController]
...
});
function DialogController($scope, $mdDialog) {/* ...*/}
附带说明,请避免在 services/factories.
中定义对话框