Shapes are not being loaded properly on routing out and coming back to the canvas component

When I reload the canvas page, it loads properly, but when we route to other page and come to the canvas again, it gives the given image error,
Reason (my guess): is that it does not properly cleanup on moving out of components.
Tech: Angular 9
Note: The templates are being added in service in angular
image
below image is how shapes are being added via nodetamplate

this is wat im using for cleanup.
image

Still not working

Here’s what the gojs-angular DiagramComponent defines for its ngOnDestroy method:

  public ngOnDestroy() {
    this.diagram.div = null; // removes event listeners
  }

I suggest that you try the same in your code.