【发布时间】:2020-10-05 21:45:31
【问题描述】:
我正在更新旧版 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) { 中时,如何在依赖项周围提供引号?
【问题讨论】:
标签: angularjs