Skip to content

IconNotFoundError when using dynamically loaded icons with Angular Universal #7240

@nicholasgerard

Description

@nicholasgerard

Reproduction link

this.ngZone.runOutsideAngular(() => {

Steps to reproduce

  1. Create a project with Angular Universal
  2. Attempt to use dynamically loaded SVG icons as described in docs with nz-icon
  3. Build for SSR and run locally
  4. App crashes

What is expected?

Icons are loaded

What is actually happening?

Angular is running on http://localhost:4000
Angular is running in development mode. Call enableProdMode() to enable production mode.
/Users/xxx/Documents/yyy/dist/zzz/server/main.js:309464
              throw error;
              ^

Error: [@ant-design/icons-angular]:the icon delete-o does not exist or is not registered.
    at IconNotFoundError (/Users/xxx/Documents/yyy/dist/zzz/server/main.js:477160:10)
    at /Users/xxx/Documents/yyy/dist/zzz/server/main.js:477315:15
Environment Info
ng-zorro-antd 13.0.1
Browser Any

See refactor of changeIcon2 in NzIconDirective 12.1.1:

this.ngZone.runOutsideAngular(() => {

It appears this throws the above error when running in a Node environment (e.g. Angular Universal).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions