angular - Angular Module Federation Webpack 和 Reactive Forms FormControl 复制
问题描述
我正在使用 Angular ModuleFederation Application 创建一个微前端应用程序。
我在 1 个微应用中有一个反应形式
<input type="text" [formControl]="email" />
<span class="text-danger" *ngIf="email.hasError('required')">This field is required</span>
所以,当我运行这个应用程序http://localhost:4201/setup
时,验证一切正常。
打包此应用程序后,
new ModuleFederationPlugin({
// For remotes (please adjust)
name: "businessSetup",
filename: "businessSetupRemoteEntry.js",
exposes: {
'./BusinessSetupModule': './projects/business-setup/src/app/components/setup/setup.module.ts',
},
shared: share({
"@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
...sharedMappings.getDescriptors()
})
}),
当我运行主机应用程序http://localhost:4200
时,会加载微应用程序,但验证时会出现奇怪的行为。它重复如下,我不知道。
托管应用程序 webpack
new ModuleFederationPlugin({
// For hosts (please adjust)
remotes: {
"businessSetup": "businessSetup@http://localhost:4201/businessSetupRemoteEntry.js",
},
shared: share({
"@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
...sharedMappings.getDescriptors()
})
}),
请问有什么线索吗?
更新:
这只是不适用于路由 url 更改
当网址为
http://localhost:4200
但不是当网址是
http://localhost:4200/test
解决方案
问题出在"@angular/animations
. 按照以下步骤操作,问题就消失了。
"@angular/animations": {singleton: true, eager: true}
在遥控器和 shell 应用程序中都添加了。- 在所有模块中删除
BrowserAnimationsModule
,除了所有app.modules
- 无需分享
@angular/platform-browser/animations
推荐阅读
- mysql - 您可以将类似的行分组在一列中,但将其他列分开吗?
- wordpress - 剥离“get_the_author_link”以仅返回 URL(不是名称、标题、目标等)
- java - 为 Kafka 流上的窗口数据创建 SerDes
- javascript - 处理样式化组件中的道具组合
- magento - 如何在 Magento 2.1.8 中显示自定义模块的模板 - 不工作
- symfony - 将 Service Worker 集成到 Symfony 项目中的问题
- java - Java 8 Streams - 从流中对类型中的多个值求和
- c - 如何修复函数的隐式声明?
- python - 如何运行 Docker 映像以查看对脚本所做的更改?
- python-3.x - 散景列可按数字排序