我正在使用ngx-smart-modal软件包使用modal。对于开发版本来说,它工作正常,但是对于生产版本而言,它却不起作用,这意味着当aot当时设置为true时,它不起作用
这是我的生产版本配置
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
这是我的角度配置
Angular CLI: 7.2.3
Node: 10.15.1
OS: linux x64
Angular: 7.2.2
... common, compiler, core, forms, language-service
... platform-browser, platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.3
@angular-devkit/build-angular 0.12.3
@angular-devkit/build-optimizer 0.12.3
@angular-devkit/build-webpack 0.12.3
@angular-devkit/core 7.2.3
@angular-devkit/schematics 7.2.3
@angular/animations 7.2.7
@angular/cdk 7.3.0
@angular/cli 7.2.3
@angular/compiler-cli 7.2.7
@ngtools/webpack 7.2.3
@schematics/angular 7.2.3
@schematics/update 0.12.3
rxjs 6.3.3
typescript 3.2.4
webpack 4.28.4
当aot设置为false时,这是我的代码,可以正常工作
// do stuffs when modal has been closed.
this.ngxSmartModalService.getModal('modal1').onClose.subscribe((modal: NgxSmartModalComponent) => {
// do something
console.log("Modal is closed");
});
// do stuffs when modal has been dismissed i.e when the modal is closed clicking in backdrop.
this.ngxSmartModalService.getModal('modal1').onDismiss.subscribe((modal: NgxSmartModalComponent) => {
// do something
console.log("Modal is closed");
});
this.ngxSmartModalService.getModal('modal1').onEscape.subscribe((modal: NgxSmartModalComponent) => {
// do something
console.log("Modal is closed");
});
根据上面的代码,预计Modal is closed
应该在浏览器的控制台中打印,但是当aot设置为true时,它不会打印日志。