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

Default Angular Template creates duplicate html and body tags #1233

Closed
RedFolder opened this issue Aug 28, 2017 · 3 comments
Closed

Default Angular Template creates duplicate html and body tags #1233

RedFolder opened this issue Aug 28, 2017 · 3 comments

Comments

@RedFolder
Copy link

Create a new ASP.NET Core 2.0 Web App with the default Angular template. Build and run. View the source. Note the html, head, and body tags located within the tag. The console also enumerates the errors. This is obviously unintended, and I assume is an artifact of the pre-renderer.

@ltctech
Copy link

ltctech commented Aug 28, 2017

I'm not sure why this is still a problem even though it was supposedly fixed:
angular/universal#347

I ended up putting the following in boot.server.ts for now:

                    resolve({
                        html: state.renderToString()
                            .replace('<html><head>', '')
                            .replace('</head><body>', '')
                            .replace(/<\s*app.*?>/,'')
                            .replace('</app></body></html>', '')
                    });

@SteveSandersonMS
Copy link
Member

SteveSandersonMS commented Sep 6, 2017

@ltctech They only fixed it temporarily, then brought back the issue in a later version unfortunately.

@MarkPieszak has been working with the Angular team on hopefully improving the APIs around server-side rendering so we can get the distinct outputs (HTML, title, styles, etc.) separately instead of them all being mashed together in a big HTML document string. If Angular does implement that then we'll certainly make use of it, but failing that @ltctech's workaround is as good as it gets.

@pravin271
Copy link

@anyone found a solution to this problem?

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

3 participants