Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

HMR injects duplicate angular markup into the page #665

Closed

Description

@stevetayloruk

When modifing a file, such as a .ts or .css file, for example:

this.currentCount++;
to
this.currentCount = this.currentCount + 2 ;

Then the component gets rendered twice in the page like so:

image

I'm using the latest yeoman project but not the experimental angular option.

thanks

Activity

  1. SteveSandersonMS commented on Feb 13, 2017

    @SteveSandersonMS
    Member

    Sorry about that. It was a mismatch between the logic needed for Angular 2.0.2 and 2.4.5+.

    To fix it, edit your boot-client.ts file, and just delete the following lines:

        // Before restarting the app, we create a new root element and dispose the old one
        const oldRootElem = document.querySelector(rootElemTagName);
        const newRootElem = document.createElement(rootElemTagName);
        oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
    

    Leave the following one (that calls platform.destroy();) in place, as that's all that's needed on Angular 2.0.2.

    This will no longer be an issue, as we've removed the option to produce projects with older versions of Angular (the Angular template now only produces 2.4.5+ projects), hence closing this.

  2. kkalitowski commented on Jul 28, 2017

    @kkalitowski

    Would you expect this to still be a problem with Microsoft.AspNetCore.SpaTemplates 0.9.3 that was using Angular 4? I'm still seeing the issue at that point (May'ish) and am wondering if the advice above is still the recommendation for that version.

  3. SteveSandersonMS commented on Aug 1, 2017

    @SteveSandersonMS
    Member

    @kkalitowski Yes, nothing's changed about that yet as far as I know.

  4. kkalitowski commented on Aug 1, 2017

    @kkalitowski

    @SteveSanderson Gotcha. And that manual fix does work. I was referring to your Feb 13 note saying there should no longer be an issue. On a positive note, TrilonIO/aspnetcore-angular-universal@a83a6a9 was merged yesterday which fixes the issue.

  5. irejwanul commented on Feb 3, 2018

    @irejwanul

    Angular 4.4.5, nothing improved yet. The solution of @SteveSanderson is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions