Angular 7 Universal: inner components are not rendered










1















I have set up Angular 7 Universal with dynamic server-side rendering. Everything works fine except for the fact that dynamic components inside the main component being server-side rendered are not rendered themselves.



Below an example rendered HTML of a header section:






<sb-app _nghost-sc0="" ng-version="7.0.3">
<sb-header _ngcontent-sc0="" _nghost-sc1="">
<div _ngcontent-sc1="" class="nav-topbar"></div>
<nav _ngcontent-sc1="" class="navbar navbar-expand-lg navbar-light p-0" id="main-navbar">
<div _ngcontent-sc1="" class="container d-flex align-items-center px-3">
<a _ngcontent-sc1="" class="navbar-brand" href="/">
<img _ngcontent-sc1="" alt="logo" class="navbar-logo" src="/assets/images/common/logo.svg" title="Logo">
</a>
<a _ngcontent-sc1="" class="cd-nav-trigger"><span _ngcontent-sc1=""></span></a><!----><!---->
<ul _ngcontent-sc1="" class="nav nav-pills d-none d-md-flex ng-star-inserted">
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="login">Login</a></li>
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="register">Register</a></li>
</ul>
</div>

<!-- THIS BELOW COMPONENT IS NOT RENDERED -->
<sb-menu _ngcontent-sc1="" class="d-block d-md-none ng-tns-c9-0" _nghost-sc9=""><!----></sb-menu>
</nav>
</sb-header>
...
</sb-app>





How do I address this issue so that also tags like <sb-menu> get rendered?










share|improve this question
























  • how is the component sb-menu imported?

    – Jibin Mathews
    Nov 14 '18 at 7:07











  • That component is imported in app.module.ts, if I import it in declarations in app.server.module.ts it tells me that I imported it twice. Should anything be added in app.server.module.ts?

    – Romeo
    Nov 14 '18 at 7:15












  • Does sb-menu refer to an external library or one of your own components?

    – YoukouleleY
    Nov 22 '18 at 14:31
















1















I have set up Angular 7 Universal with dynamic server-side rendering. Everything works fine except for the fact that dynamic components inside the main component being server-side rendered are not rendered themselves.



Below an example rendered HTML of a header section:






<sb-app _nghost-sc0="" ng-version="7.0.3">
<sb-header _ngcontent-sc0="" _nghost-sc1="">
<div _ngcontent-sc1="" class="nav-topbar"></div>
<nav _ngcontent-sc1="" class="navbar navbar-expand-lg navbar-light p-0" id="main-navbar">
<div _ngcontent-sc1="" class="container d-flex align-items-center px-3">
<a _ngcontent-sc1="" class="navbar-brand" href="/">
<img _ngcontent-sc1="" alt="logo" class="navbar-logo" src="/assets/images/common/logo.svg" title="Logo">
</a>
<a _ngcontent-sc1="" class="cd-nav-trigger"><span _ngcontent-sc1=""></span></a><!----><!---->
<ul _ngcontent-sc1="" class="nav nav-pills d-none d-md-flex ng-star-inserted">
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="login">Login</a></li>
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="register">Register</a></li>
</ul>
</div>

<!-- THIS BELOW COMPONENT IS NOT RENDERED -->
<sb-menu _ngcontent-sc1="" class="d-block d-md-none ng-tns-c9-0" _nghost-sc9=""><!----></sb-menu>
</nav>
</sb-header>
...
</sb-app>





How do I address this issue so that also tags like <sb-menu> get rendered?










share|improve this question
























  • how is the component sb-menu imported?

    – Jibin Mathews
    Nov 14 '18 at 7:07











  • That component is imported in app.module.ts, if I import it in declarations in app.server.module.ts it tells me that I imported it twice. Should anything be added in app.server.module.ts?

    – Romeo
    Nov 14 '18 at 7:15












  • Does sb-menu refer to an external library or one of your own components?

    – YoukouleleY
    Nov 22 '18 at 14:31














1












1








1


0






I have set up Angular 7 Universal with dynamic server-side rendering. Everything works fine except for the fact that dynamic components inside the main component being server-side rendered are not rendered themselves.



Below an example rendered HTML of a header section:






<sb-app _nghost-sc0="" ng-version="7.0.3">
<sb-header _ngcontent-sc0="" _nghost-sc1="">
<div _ngcontent-sc1="" class="nav-topbar"></div>
<nav _ngcontent-sc1="" class="navbar navbar-expand-lg navbar-light p-0" id="main-navbar">
<div _ngcontent-sc1="" class="container d-flex align-items-center px-3">
<a _ngcontent-sc1="" class="navbar-brand" href="/">
<img _ngcontent-sc1="" alt="logo" class="navbar-logo" src="/assets/images/common/logo.svg" title="Logo">
</a>
<a _ngcontent-sc1="" class="cd-nav-trigger"><span _ngcontent-sc1=""></span></a><!----><!---->
<ul _ngcontent-sc1="" class="nav nav-pills d-none d-md-flex ng-star-inserted">
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="login">Login</a></li>
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="register">Register</a></li>
</ul>
</div>

<!-- THIS BELOW COMPONENT IS NOT RENDERED -->
<sb-menu _ngcontent-sc1="" class="d-block d-md-none ng-tns-c9-0" _nghost-sc9=""><!----></sb-menu>
</nav>
</sb-header>
...
</sb-app>





How do I address this issue so that also tags like <sb-menu> get rendered?










share|improve this question
















I have set up Angular 7 Universal with dynamic server-side rendering. Everything works fine except for the fact that dynamic components inside the main component being server-side rendered are not rendered themselves.



Below an example rendered HTML of a header section:






<sb-app _nghost-sc0="" ng-version="7.0.3">
<sb-header _ngcontent-sc0="" _nghost-sc1="">
<div _ngcontent-sc1="" class="nav-topbar"></div>
<nav _ngcontent-sc1="" class="navbar navbar-expand-lg navbar-light p-0" id="main-navbar">
<div _ngcontent-sc1="" class="container d-flex align-items-center px-3">
<a _ngcontent-sc1="" class="navbar-brand" href="/">
<img _ngcontent-sc1="" alt="logo" class="navbar-logo" src="/assets/images/common/logo.svg" title="Logo">
</a>
<a _ngcontent-sc1="" class="cd-nav-trigger"><span _ngcontent-sc1=""></span></a><!----><!---->
<ul _ngcontent-sc1="" class="nav nav-pills d-none d-md-flex ng-star-inserted">
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="login">Login</a></li>
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="register">Register</a></li>
</ul>
</div>

<!-- THIS BELOW COMPONENT IS NOT RENDERED -->
<sb-menu _ngcontent-sc1="" class="d-block d-md-none ng-tns-c9-0" _nghost-sc9=""><!----></sb-menu>
</nav>
</sb-header>
...
</sb-app>





How do I address this issue so that also tags like <sb-menu> get rendered?






<sb-app _nghost-sc0="" ng-version="7.0.3">
<sb-header _ngcontent-sc0="" _nghost-sc1="">
<div _ngcontent-sc1="" class="nav-topbar"></div>
<nav _ngcontent-sc1="" class="navbar navbar-expand-lg navbar-light p-0" id="main-navbar">
<div _ngcontent-sc1="" class="container d-flex align-items-center px-3">
<a _ngcontent-sc1="" class="navbar-brand" href="/">
<img _ngcontent-sc1="" alt="logo" class="navbar-logo" src="/assets/images/common/logo.svg" title="Logo">
</a>
<a _ngcontent-sc1="" class="cd-nav-trigger"><span _ngcontent-sc1=""></span></a><!----><!---->
<ul _ngcontent-sc1="" class="nav nav-pills d-none d-md-flex ng-star-inserted">
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="login">Login</a></li>
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="register">Register</a></li>
</ul>
</div>

<!-- THIS BELOW COMPONENT IS NOT RENDERED -->
<sb-menu _ngcontent-sc1="" class="d-block d-md-none ng-tns-c9-0" _nghost-sc9=""><!----></sb-menu>
</nav>
</sb-header>
...
</sb-app>





<sb-app _nghost-sc0="" ng-version="7.0.3">
<sb-header _ngcontent-sc0="" _nghost-sc1="">
<div _ngcontent-sc1="" class="nav-topbar"></div>
<nav _ngcontent-sc1="" class="navbar navbar-expand-lg navbar-light p-0" id="main-navbar">
<div _ngcontent-sc1="" class="container d-flex align-items-center px-3">
<a _ngcontent-sc1="" class="navbar-brand" href="/">
<img _ngcontent-sc1="" alt="logo" class="navbar-logo" src="/assets/images/common/logo.svg" title="Logo">
</a>
<a _ngcontent-sc1="" class="cd-nav-trigger"><span _ngcontent-sc1=""></span></a><!----><!---->
<ul _ngcontent-sc1="" class="nav nav-pills d-none d-md-flex ng-star-inserted">
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="login">Login</a></li>
<li _ngcontent-sc1="" class="nav-item"><a _ngcontent-sc1="" class="nav-link" id="register">Register</a></li>
</ul>
</div>

<!-- THIS BELOW COMPONENT IS NOT RENDERED -->
<sb-menu _ngcontent-sc1="" class="d-block d-md-none ng-tns-c9-0" _nghost-sc9=""><!----></sb-menu>
</nav>
</sb-header>
...
</sb-app>






javascript angular serverside-rendering angular-universal angular7






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 14:01









Goncalo Peres

1,4691619




1,4691619










asked Nov 14 '18 at 7:00









RomeoRomeo

101119




101119












  • how is the component sb-menu imported?

    – Jibin Mathews
    Nov 14 '18 at 7:07











  • That component is imported in app.module.ts, if I import it in declarations in app.server.module.ts it tells me that I imported it twice. Should anything be added in app.server.module.ts?

    – Romeo
    Nov 14 '18 at 7:15












  • Does sb-menu refer to an external library or one of your own components?

    – YoukouleleY
    Nov 22 '18 at 14:31


















  • how is the component sb-menu imported?

    – Jibin Mathews
    Nov 14 '18 at 7:07











  • That component is imported in app.module.ts, if I import it in declarations in app.server.module.ts it tells me that I imported it twice. Should anything be added in app.server.module.ts?

    – Romeo
    Nov 14 '18 at 7:15












  • Does sb-menu refer to an external library or one of your own components?

    – YoukouleleY
    Nov 22 '18 at 14:31

















how is the component sb-menu imported?

– Jibin Mathews
Nov 14 '18 at 7:07





how is the component sb-menu imported?

– Jibin Mathews
Nov 14 '18 at 7:07













That component is imported in app.module.ts, if I import it in declarations in app.server.module.ts it tells me that I imported it twice. Should anything be added in app.server.module.ts?

– Romeo
Nov 14 '18 at 7:15






That component is imported in app.module.ts, if I import it in declarations in app.server.module.ts it tells me that I imported it twice. Should anything be added in app.server.module.ts?

– Romeo
Nov 14 '18 at 7:15














Does sb-menu refer to an external library or one of your own components?

– YoukouleleY
Nov 22 '18 at 14:31






Does sb-menu refer to an external library or one of your own components?

– YoukouleleY
Nov 22 '18 at 14:31













1 Answer
1






active

oldest

votes


















1














You should be aware that Angular Universal relies on the fact that your code uses only Angular mechanisms and never uses the browser API (window, document, navigator, etc...) since these objects do not exist in Node.js.



Also, if one of your components relies on an external library loaded via a script tag, that won't work either, since Node.js won't load client scripts when performing server-side rendering.



If one of your components doesn't render, it's probably because your code doesn't comply with the rules above.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294689%2fangular-7-universal-inner-components-are-not-rendered%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You should be aware that Angular Universal relies on the fact that your code uses only Angular mechanisms and never uses the browser API (window, document, navigator, etc...) since these objects do not exist in Node.js.



    Also, if one of your components relies on an external library loaded via a script tag, that won't work either, since Node.js won't load client scripts when performing server-side rendering.



    If one of your components doesn't render, it's probably because your code doesn't comply with the rules above.






    share|improve this answer



























      1














      You should be aware that Angular Universal relies on the fact that your code uses only Angular mechanisms and never uses the browser API (window, document, navigator, etc...) since these objects do not exist in Node.js.



      Also, if one of your components relies on an external library loaded via a script tag, that won't work either, since Node.js won't load client scripts when performing server-side rendering.



      If one of your components doesn't render, it's probably because your code doesn't comply with the rules above.






      share|improve this answer

























        1












        1








        1







        You should be aware that Angular Universal relies on the fact that your code uses only Angular mechanisms and never uses the browser API (window, document, navigator, etc...) since these objects do not exist in Node.js.



        Also, if one of your components relies on an external library loaded via a script tag, that won't work either, since Node.js won't load client scripts when performing server-side rendering.



        If one of your components doesn't render, it's probably because your code doesn't comply with the rules above.






        share|improve this answer













        You should be aware that Angular Universal relies on the fact that your code uses only Angular mechanisms and never uses the browser API (window, document, navigator, etc...) since these objects do not exist in Node.js.



        Also, if one of your components relies on an external library loaded via a script tag, that won't work either, since Node.js won't load client scripts when performing server-side rendering.



        If one of your components doesn't render, it's probably because your code doesn't comply with the rules above.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 14:40









        YoukouleleYYoukouleleY

        2,6861826




        2,6861826





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294689%2fangular-7-universal-inner-components-are-not-rendered%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo