Windows is not defined aot, ssr angular

Posted by: trac.do on 30 April 2018, 7:00 am EST

    • Post Options:
    • Link

    Posted 30 April 2018, 7:00 am EST

    Hi,

    I am using aspnet core web app project with angular template within VS2017 and add wijmo into the project using npm. A simple run would produce error : Prerendering failed because of error: ReferenceError: window is not defined.

    I am also using webpack with server side rendering. of course ‘window’ won’t be there but it’s being used by wijmo library. Do you have fix for this or a way around it? Other forums suggested putting conditional statement around the code to bypass window but it woulnd’t make sense to make change to your code base.

    I am putting this inside the appshared.module.ts . moving them to app.browser.ts then the app doesn’t see the import at all.

    Please advise.

    Thanks

    import { WjGridModule, WjFlexGrid, WjFlexGridColumn, WjFlexGridCellTemplate } from ‘wijmo/wijmo.angular2.grid’;

    and

    declarations: [ WjPopup,

    WjAutoComplete,

    WjComboBox,

    WjInputDate,

    WjInputNumber,

    WjInputMask,

    WjListBox

  • Posted 30 April 2018, 11:06 pm EST

    Hi,

    We are able to replicate the issue at our end. This issue has been forwarded to the concerned team for further investigation with tracking id 319915.

    We will let you know as we get any error on this.

    ~Manish

  • Posted 1 May 2018, 12:55 am EST

    Hi Trac,

    Could you please let us know how you create your Application for investigation?

    We tried to create just using Angular Project template provided by VS 2017 for ASP.Net core application.

    If you can share a demo application, it would be great help for us to investigate the issue.

    ~Manish

  • Posted 1 May 2018, 2:37 am EST

    Within VS2017 with .net core 2.0 sdk installed, go to new project, pick from .net core, Asp.net core web application, hit OK. At the next screen, make sure .net core 2.0 is picked from the drop down at the top, pick Angular template from the options in the main window. Once is the project is created, go to package.json and add in wijmo from the npm. Put a wijmo control into one of the component and run it, you will see the error.

  • Posted 2 May 2018, 10:12 pm EST

    Hi,

    Thank you for your information.

    We are sorry indeed, with current Wijmo version, Wijmo may not be used in the application that uses server-side rendering.

    To use Wijmo with Asp.Net Core, you needs to disable server-side rendering.

    Please refer to the following code snippet and attached index.cshtml file:

    @*<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>*@
    <app >Loading...</app>
    

    Alternatively, you may also use C1MVC ASP.Net core controls for server side controls.

    https://www.grapecity.com/en/aspnet-mvc#demos

    ~Manish

    Index.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels