Angular SVG 图标不适用于 Angular 通用项目延迟加载模块
Angular SVG Icon not work with Angular Universal project lazy loading module
Anguler: 11.2.5
typescript: 4.0.2
angular-svg-icon: 11.2.0
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppHomeModule)[SvgIconRegistryService -> SvgIconRegistryService -> SvgLoader -> TransferState -> TransferState -> TransferState]:
NullInjectorError: No provider for TransferState!
NullInjectorError: R3InjectorError(AppHomeModule)[SvgIconRegistryService -> SvgIconRegistryService -> SvgLoader -> TransferState -> TransferState -> TransferState]:
分量html:
<svg-icon src="call.svg" [svgStyle]="{ 'width.px':90 }"></svg-icon>
懒加载模块调用:
imports: [
...
AngularSvgIconModule
],
app.module.ts
您需要在客户端 (app.module.ts
) 导入 BrowserTransferStateModule
并在服务器端 (app.server.module.ts
) 导入 ServerTransferStateModule
Anguler: 11.2.5
typescript: 4.0.2
angular-svg-icon: 11.2.0
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppHomeModule)[SvgIconRegistryService -> SvgIconRegistryService -> SvgLoader -> TransferState -> TransferState -> TransferState]:
NullInjectorError: No provider for TransferState!
NullInjectorError: R3InjectorError(AppHomeModule)[SvgIconRegistryService -> SvgIconRegistryService -> SvgLoader -> TransferState -> TransferState -> TransferState]:
分量html:
<svg-icon src="call.svg" [svgStyle]="{ 'width.px':90 }"></svg-icon>
懒加载模块调用:
imports: [
...
AngularSvgIconModule
],
app.module.ts
您需要在客户端 (app.module.ts
) 导入 BrowserTransferStateModule
并在服务器端 (app.server.module.ts
) 导入 ServerTransferStateModule