angular / universal-starter

Angular Universal starter kit by @AngularClass
2.02k stars 688 forks source link

<router-outlet> tag content not rendered #468

Closed mbero closed 6 years ago

mbero commented 6 years ago

Hello

I'm using universal-starter project configuration in my Angular4 application. Everything is working pretty smooth beside one thing: When i'm using f.e curl http://localhost:3000/homepage I get whole HTML rendered by server side.

But when i type : curl http://localhost:3000/somesubpage/someid/

in places which i use routing and tag <router-outlet> i didnt get properly rendered content ( in response i have whole html without content which should be rendered in <router-outlet>) .

Maybe i didnt understand something - but it's that issue of server.ts configuration or something different ? I will appreciate any help.

jongood01 commented 6 years ago

I have the same issue and can't figure out what is causing it. If I create a new component in the unaltered universal-starter/cli project it works fine (tested with external template files and sass files and both work fine). But in my own project the route is not rendered only content outside the route-outlet. There are no errors during compile or on the node server once it's running.

jongood01 commented 6 years ago

I have solved the issue on my project it was a custom route reuse strategy we were using. For debugging your case I recommend branching your project and deleting everything for a simple component that works. Then add the pieces back in until it works.

mbero commented 6 years ago

jongood01 : Thanks for answer - i will let you know if (and how) i solve this

jongood01 commented 6 years ago

Specifically the issue was a simple console.debug() in the custom route reuse strategy - node doesn't have the debug method. Look out for apis like this that don't exist server-side.

MarkPieszak commented 6 years ago

Closing out as it looks like you guys got it figured out!

elSuperRiton commented 6 years ago

Hey guys, got sort of a similar issue here.

I have my router wrapped around a canActivateChild that sends a request to an api in order to get some config before rendering. Had to do it this way since the APP_INITIALIZER still allows the router to render.

Anyways, the router outlet is completely empty when using server side rendering and I have no clue if that comes from delaying the routing or a conflicting module ( as the project is already quite advanced and I've joined it recently ).

Any other way to debug than commenting out modules and components one by one ?

adrigardi90 commented 6 years ago

Hey, my project is quite advanced as well and I'm getting the same issue you've explained.

In my case the problem is the canActivate param. If I define it for the routing, the server side render does not show any content for the router-outlet. However, if I remove it, everything works and the content is render correctly. I'll try to check what is happening.

Starting for the most simple case in your project, try to add different simple pieces to figure out what is happening as joongod01 said.

nimatrazmjo commented 5 years ago

I have the same issue. Data does not render inside of router-outlet.

<app-root _nghost-sc0="" ng-version="6.1.10" class="layout-fixed"><ngx-loading-bar _ngcontent-sc0="" color="#ff6849" _nghost-sc1="" class="loading-bar-fixed"><!----></ngx-loading-bar><router-outlet _ngcontent-sc0=""></router-outlet></app-root>
GeoffMahugu commented 5 years ago

Any fix for this issue. having the same problem

BruneXX commented 5 years ago

Hi Guys, same problem here, I've child routes that aren't rendering, do you have any ideas. My configuration is inner/outer routes having three tags. One for inner component, another for an outer component, and the main tag, placed in app.component.html. Anyone knows if this is a bug from universal? or will not work with that inner/outer approach?