aspnetcore-angular-universal icon indicating copy to clipboard operation
aspnetcore-angular-universal copied to clipboard

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

Open naveedahmed1 opened this issue 8 years ago • 7 comments

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.

naveedahmed1 avatar Oct 23 '17 15:10 naveedahmed1

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)

MarkPieszak avatar Oct 30 '17 13:10 MarkPieszak

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

naveedahmed1 avatar Oct 30 '17 14:10 naveedahmed1

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

MarkPieszak avatar Nov 02 '17 14:11 MarkPieszak

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

isaacrlevin avatar Nov 15 '17 20:11 isaacrlevin

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

naveedahmed1 avatar Nov 15 '17 21:11 naveedahmed1

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

riiight avatar May 03 '18 00:05 riiight

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

isaacrlevin avatar May 03 '18 02:05 isaacrlevin