Exclude component that breaks Angular UniversalAngular no provider for NameServiceAngular HTML binding@Directive v/s @Component in AngularHow can I select an element in a component template?How can I get new selection in “select” in Angular 2?Angular - Use pipes in services and componentsAngular pass callback function to child component as @Input similar to AngularJS wayHow do I pass data to Angular routed components?Huge number of files generated for every Angular projectAngular universal / ng-toolkit/universal throws error when image doesn't exist

When I get angry, you buy me silver or gold

Combining two plots with separate frame tick styles

What are the units of the product of two signals?

How can you weaponize a thermos?

Why Philipine 113 /Boeing 777 didnt dump fuel prior to forced landing?

Is Stoch enriched in Met?

A Ukrainian idiom meaning "on one's last legs"

Convention for inverted signal

Why is SpaceX not also working on a smaller version of Starship?

How to prepend a character to start of each line in 250,000+ line file using a script?

Is there a product for channeling water away from water appliances?

Why is it ethical for Ambassador Sondland to have been given an ambassadorship for campaign contributions?

How does "unlimited holidays" in practice work?

Can Teflon thread tape be reused?

Why wasn't Vader's armour made of Beskar?

Is there any theory why (for Bitcoin) the discrete logarithm problem is so hard to solve?

Why 401k contribution as % of salary vs. fixed amount per pay check?

Why would Earth be long-term unsuitable for an advanced alien species that's already colonized it?

Do Klingons have escape pods?

How can I edit rendering parameters programatically?

New Command for Comment?

Is Fox News not classified as a news channel?

How often are there lunar eclipses on Jupiter

I peer reviewed a paper and found it to be sound - technically and language-wise. How should I write the review report?



Exclude component that breaks Angular Universal


Angular no provider for NameServiceAngular HTML binding@Directive v/s @Component in AngularHow can I select an element in a component template?How can I get new selection in “select” in Angular 2?Angular - Use pipes in services and componentsAngular pass callback function to child component as @Input similar to AngularJS wayHow do I pass data to Angular routed components?Huge number of files generated for every Angular projectAngular universal / ng-toolkit/universal throws error when image doesn't exist






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









2


















I used ng-toolkit with ng add @ng-toolkit/universal to add Angular Universal support to my project.



I am able to create the prod build with no errors plus I am able to run the server, again without any errors. It just get "stuck" when request comes to it (nodeJS does not render any output).



I found out, that one of my components is breaking server-side rendering. I found out that the issue is with the Mat-Carousel:



component:



export class BannerComponent 

slides: any[] = [
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-one.png' ,
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-two.png' ,
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-three.png'
];




template:



<section class="sec-space-b" id="banner">
<mat-carousel
timings="250ms ease-in"
[autoplay]="true"
interval="5000"
color="accent"
maxWidth="auto"
proportion="25"
slides="5"
[loop]="true"
[hideArrows]="false"
[hideIndicators]="false"
[useKeyboard]="true"
[useMouseWheel]="false"
orientation="ltr"
>
<mat-carousel-slide
#matCarouselSlide
*ngFor="let slide of slides; let i = index"
overlayColor="#00000000"
[image]="slide.image"
[hideOverlay]="false"
></mat-carousel-slide>
</mat-carousel>
</section>


How can I solve this problem? Can I somehow exclude particular component from the Server-Side build?










share|improve this question



























  • do you see any errors in the browser debug console. can you also share the contents of the scripts ? what does npm xxxx actually do

    – jcuypers
    Mar 28 at 22:08












  • here you can find the whole the repo: github.com/immad-hamid/website-csn and the packages I have used. Well I have used ng-toolkit. No error at all, not even the browser's console the browser shows nothing

    – Immad Hamid
    Mar 28 at 23:38


















2


















I used ng-toolkit with ng add @ng-toolkit/universal to add Angular Universal support to my project.



I am able to create the prod build with no errors plus I am able to run the server, again without any errors. It just get "stuck" when request comes to it (nodeJS does not render any output).



I found out, that one of my components is breaking server-side rendering. I found out that the issue is with the Mat-Carousel:



component:



export class BannerComponent 

slides: any[] = [
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-one.png' ,
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-two.png' ,
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-three.png'
];




template:



<section class="sec-space-b" id="banner">
<mat-carousel
timings="250ms ease-in"
[autoplay]="true"
interval="5000"
color="accent"
maxWidth="auto"
proportion="25"
slides="5"
[loop]="true"
[hideArrows]="false"
[hideIndicators]="false"
[useKeyboard]="true"
[useMouseWheel]="false"
orientation="ltr"
>
<mat-carousel-slide
#matCarouselSlide
*ngFor="let slide of slides; let i = index"
overlayColor="#00000000"
[image]="slide.image"
[hideOverlay]="false"
></mat-carousel-slide>
</mat-carousel>
</section>


How can I solve this problem? Can I somehow exclude particular component from the Server-Side build?










share|improve this question



























  • do you see any errors in the browser debug console. can you also share the contents of the scripts ? what does npm xxxx actually do

    – jcuypers
    Mar 28 at 22:08












  • here you can find the whole the repo: github.com/immad-hamid/website-csn and the packages I have used. Well I have used ng-toolkit. No error at all, not even the browser's console the browser shows nothing

    – Immad Hamid
    Mar 28 at 23:38














2













2









2








I used ng-toolkit with ng add @ng-toolkit/universal to add Angular Universal support to my project.



I am able to create the prod build with no errors plus I am able to run the server, again without any errors. It just get "stuck" when request comes to it (nodeJS does not render any output).



I found out, that one of my components is breaking server-side rendering. I found out that the issue is with the Mat-Carousel:



component:



export class BannerComponent 

slides: any[] = [
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-one.png' ,
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-two.png' ,
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-three.png'
];




template:



<section class="sec-space-b" id="banner">
<mat-carousel
timings="250ms ease-in"
[autoplay]="true"
interval="5000"
color="accent"
maxWidth="auto"
proportion="25"
slides="5"
[loop]="true"
[hideArrows]="false"
[hideIndicators]="false"
[useKeyboard]="true"
[useMouseWheel]="false"
orientation="ltr"
>
<mat-carousel-slide
#matCarouselSlide
*ngFor="let slide of slides; let i = index"
overlayColor="#00000000"
[image]="slide.image"
[hideOverlay]="false"
></mat-carousel-slide>
</mat-carousel>
</section>


How can I solve this problem? Can I somehow exclude particular component from the Server-Side build?










share|improve this question
















I used ng-toolkit with ng add @ng-toolkit/universal to add Angular Universal support to my project.



I am able to create the prod build with no errors plus I am able to run the server, again without any errors. It just get "stuck" when request comes to it (nodeJS does not render any output).



I found out, that one of my components is breaking server-side rendering. I found out that the issue is with the Mat-Carousel:



component:



export class BannerComponent 

slides: any[] = [
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-one.png' ,
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-two.png' ,
// tslint:disable-next-line:max-line-length
image: 'assets/banner/banner-three.png'
];




template:



<section class="sec-space-b" id="banner">
<mat-carousel
timings="250ms ease-in"
[autoplay]="true"
interval="5000"
color="accent"
maxWidth="auto"
proportion="25"
slides="5"
[loop]="true"
[hideArrows]="false"
[hideIndicators]="false"
[useKeyboard]="true"
[useMouseWheel]="false"
orientation="ltr"
>
<mat-carousel-slide
#matCarouselSlide
*ngFor="let slide of slides; let i = index"
overlayColor="#00000000"
[image]="slide.image"
[hideOverlay]="false"
></mat-carousel-slide>
</mat-carousel>
</section>


How can I solve this problem? Can I somehow exclude particular component from the Server-Side build?







angular typescript nodes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 9 at 12:12









Maciej Treder

6,9383 gold badges35 silver badges59 bronze badges




6,9383 gold badges35 silver badges59 bronze badges










asked Mar 28 at 22:03









Immad HamidImmad Hamid

4233 silver badges14 bronze badges




4233 silver badges14 bronze badges















  • do you see any errors in the browser debug console. can you also share the contents of the scripts ? what does npm xxxx actually do

    – jcuypers
    Mar 28 at 22:08












  • here you can find the whole the repo: github.com/immad-hamid/website-csn and the packages I have used. Well I have used ng-toolkit. No error at all, not even the browser's console the browser shows nothing

    – Immad Hamid
    Mar 28 at 23:38


















  • do you see any errors in the browser debug console. can you also share the contents of the scripts ? what does npm xxxx actually do

    – jcuypers
    Mar 28 at 22:08












  • here you can find the whole the repo: github.com/immad-hamid/website-csn and the packages I have used. Well I have used ng-toolkit. No error at all, not even the browser's console the browser shows nothing

    – Immad Hamid
    Mar 28 at 23:38

















do you see any errors in the browser debug console. can you also share the contents of the scripts ? what does npm xxxx actually do

– jcuypers
Mar 28 at 22:08






do you see any errors in the browser debug console. can you also share the contents of the scripts ? what does npm xxxx actually do

– jcuypers
Mar 28 at 22:08














here you can find the whole the repo: github.com/immad-hamid/website-csn and the packages I have used. Well I have used ng-toolkit. No error at all, not even the browser's console the browser shows nothing

– Immad Hamid
Mar 28 at 23:38






here you can find the whole the repo: github.com/immad-hamid/website-csn and the packages I have used. Well I have used ng-toolkit. No error at all, not even the browser's console the browser shows nothing

– Immad Hamid
Mar 28 at 23:38













1 Answer
1






active

oldest

votes


















2



















The fix is simple, you should use a PLATFORM_ID token together with the isPlatformBrowser or isPlatformServer method.



Inside your template use the #ngIf statement:



<section class="sec-space-b" id="banner" *ngIf="isBrowser">


And inside the component code initialize the isBrowser field as:



import isPlatformBrowser from '@angular/common';
import Component, OnInit, Inject, PLATFORM_ID from '@angular/core';


@Component(
selector: 'app-home-banner',
templateUrl: './banner.component.html',
styleUrls: ['./banner.component.scss']
)
export class BannerComponent implements OnInit

public isBrowser = isPlatformBrowser(this.platformId);

constructor(@Inject(PLATFORM_ID) private platformId: any)



You can read more about isPlatformServer and isPlatformBrowser in this article (they are used there):
https://www.twilio.com/blog/create-search-engine-friendly-internationalized-web-apps-angular-universal-ngx-translate



You can also check out my talk about Angular Universal (13:26 - about running different code on browser and server):
https://www.youtube.com/watch?v=J42mqpVsg0k






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/4.0/"u003ecc by-sa 4.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%2f55407541%2fexclude-component-that-breaks-angular-universal%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









    2



















    The fix is simple, you should use a PLATFORM_ID token together with the isPlatformBrowser or isPlatformServer method.



    Inside your template use the #ngIf statement:



    <section class="sec-space-b" id="banner" *ngIf="isBrowser">


    And inside the component code initialize the isBrowser field as:



    import isPlatformBrowser from '@angular/common';
    import Component, OnInit, Inject, PLATFORM_ID from '@angular/core';


    @Component(
    selector: 'app-home-banner',
    templateUrl: './banner.component.html',
    styleUrls: ['./banner.component.scss']
    )
    export class BannerComponent implements OnInit

    public isBrowser = isPlatformBrowser(this.platformId);

    constructor(@Inject(PLATFORM_ID) private platformId: any)



    You can read more about isPlatformServer and isPlatformBrowser in this article (they are used there):
    https://www.twilio.com/blog/create-search-engine-friendly-internationalized-web-apps-angular-universal-ngx-translate



    You can also check out my talk about Angular Universal (13:26 - about running different code on browser and server):
    https://www.youtube.com/watch?v=J42mqpVsg0k






    share|improve this answer






























      2



















      The fix is simple, you should use a PLATFORM_ID token together with the isPlatformBrowser or isPlatformServer method.



      Inside your template use the #ngIf statement:



      <section class="sec-space-b" id="banner" *ngIf="isBrowser">


      And inside the component code initialize the isBrowser field as:



      import isPlatformBrowser from '@angular/common';
      import Component, OnInit, Inject, PLATFORM_ID from '@angular/core';


      @Component(
      selector: 'app-home-banner',
      templateUrl: './banner.component.html',
      styleUrls: ['./banner.component.scss']
      )
      export class BannerComponent implements OnInit

      public isBrowser = isPlatformBrowser(this.platformId);

      constructor(@Inject(PLATFORM_ID) private platformId: any)



      You can read more about isPlatformServer and isPlatformBrowser in this article (they are used there):
      https://www.twilio.com/blog/create-search-engine-friendly-internationalized-web-apps-angular-universal-ngx-translate



      You can also check out my talk about Angular Universal (13:26 - about running different code on browser and server):
      https://www.youtube.com/watch?v=J42mqpVsg0k






      share|improve this answer




























        2















        2











        2









        The fix is simple, you should use a PLATFORM_ID token together with the isPlatformBrowser or isPlatformServer method.



        Inside your template use the #ngIf statement:



        <section class="sec-space-b" id="banner" *ngIf="isBrowser">


        And inside the component code initialize the isBrowser field as:



        import isPlatformBrowser from '@angular/common';
        import Component, OnInit, Inject, PLATFORM_ID from '@angular/core';


        @Component(
        selector: 'app-home-banner',
        templateUrl: './banner.component.html',
        styleUrls: ['./banner.component.scss']
        )
        export class BannerComponent implements OnInit

        public isBrowser = isPlatformBrowser(this.platformId);

        constructor(@Inject(PLATFORM_ID) private platformId: any)



        You can read more about isPlatformServer and isPlatformBrowser in this article (they are used there):
        https://www.twilio.com/blog/create-search-engine-friendly-internationalized-web-apps-angular-universal-ngx-translate



        You can also check out my talk about Angular Universal (13:26 - about running different code on browser and server):
        https://www.youtube.com/watch?v=J42mqpVsg0k






        share|improve this answer














        The fix is simple, you should use a PLATFORM_ID token together with the isPlatformBrowser or isPlatformServer method.



        Inside your template use the #ngIf statement:



        <section class="sec-space-b" id="banner" *ngIf="isBrowser">


        And inside the component code initialize the isBrowser field as:



        import isPlatformBrowser from '@angular/common';
        import Component, OnInit, Inject, PLATFORM_ID from '@angular/core';


        @Component(
        selector: 'app-home-banner',
        templateUrl: './banner.component.html',
        styleUrls: ['./banner.component.scss']
        )
        export class BannerComponent implements OnInit

        public isBrowser = isPlatformBrowser(this.platformId);

        constructor(@Inject(PLATFORM_ID) private platformId: any)



        You can read more about isPlatformServer and isPlatformBrowser in this article (they are used there):
        https://www.twilio.com/blog/create-search-engine-friendly-internationalized-web-apps-angular-universal-ngx-translate



        You can also check out my talk about Angular Universal (13:26 - about running different code on browser and server):
        https://www.youtube.com/watch?v=J42mqpVsg0k







        share|improve this answer













        share|improve this answer




        share|improve this answer










        answered Apr 9 at 12:20









        Maciej TrederMaciej Treder

        6,9383 gold badges35 silver badges59 bronze badges




        6,9383 gold badges35 silver badges59 bronze badges

































            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%2f55407541%2fexclude-component-that-breaks-angular-universal%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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript