TrilonIO / aspnetcore-angular-universal

ASP.NET Core & Angular Universal advanced starter - PWA w/ server-side rendering for SEO, Bootstrap, i18n internationalization, TypeScript, unit testing, WebAPI REST setup, SignalR, Swagger docs, and more! By @TrilonIO
https://www.trilon.io
MIT License
1.46k stars 433 forks source link

Issues in angular-5.0-updates repo when using ServerTransferStateModule from angular/platform-server #448

Open naveedahmed1 opened 7 years ago

naveedahmed1 commented 7 years ago

I tried adding ServerTransferStateModule and BrowserTransferStateModule from @angular/platform-server' and @angular/platform-browser respectively.

As suggested https://next.angular.io/api/platform-server/ServerTransferStateModule and https://medium.com/@evertonrobertoauler/angular-5-universal-with-transfer-state-using-angular-cli-19fe1e1d352c

But after this change, I am now receiving error Error: The selector "app-root" did not match any elements and no markup is generated at server.

Any help and guidance would be highly appreciated.

MarkPieszak commented 7 years ago

I'll take a look! It's something in the timing of how/when it's serializing the data (or where we need to be grabbing it from, that's different in the aspnet use-case)

naveedahmed1 commented 7 years ago

Thank you, it should at least render the app shell. Nothing is returned in markup from server.

MarkPieszak commented 7 years ago

Merged 5.0 into Master but left this one commented out (in app.server) for now, until we can figure out the root cause.

isaacrlevin commented 6 years ago

I think your issue is around your component. What is your selector in app.component.ts? It should be app-root. Also what is the selector in boot.server.ts, should be

naveedahmed1 commented 6 years ago

@isaac2004 no its not an issue of selector, I have confirmed it. The issue is no markup is generated at server, i.e. server doesn't get any response from node, hence it doesn't write anything to View as a result there isn't any app root tag in markup returned from server and when angular app initializes on client side it throws this error. I think @MarkPieszak has the idea about the issue. Its something related to asp.net engine.

riiight commented 6 years ago

Is there any update or workaround for this? This is preventing us from being able to use SSR.

EDIT: It looks like this may be fixed now if you update your code (though I haven't tried it yet): https://github.com/MarkPieszak/aspnetcore-angular2-universal/issues/555

isaacrlevin commented 6 years ago

This repo has everything you need for SSR. Have you pulled latest?