Skip to content
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
stevetayloruk opened this issue Feb 11, 2017 · 5 comments
Closed

HMR injects duplicate angular markup into the page #665

stevetayloruk opened this issue Feb 11, 2017 · 5 comments

Comments

@stevetayloruk
Copy link

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

SteveSandersonMS added a commit that referenced this issue Feb 13, 2017
…standard Angular one. Makes issue #665 no longer apply.
@SteveSandersonMS
Copy link
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.

@kkalitowski
Copy link

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.

@SteveSandersonMS
Copy link
Member

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

@kkalitowski
Copy link

kkalitowski commented Aug 1, 2017

@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.

@irejwanul
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants