jsreport-browser-client-dist and Angular 4



  • I am trying to integrate JSReport with my Angular 4 app. I am using jsreport-browser-client-dist. I have created a template on JSReportOnline and trying to render the report in the application.

    jsreport.serverUrl = 'https://aarfid.jsreportonline.net/api/report';

    At this line I get an error that jsreport is undefined. I have imported the jsreport module as, however i am not sure whether its a correct way or not.

    import { jsreport } from 'jsreport-browser-client-dist/jsreport';


  • administrators

    hi! hmm it depends on how your application (or more specifically the bundler in your app) treat modules that are required.

    does it work with one of the following?

    • import jsreport from 'jsreport-browser-client-dist/jsreport';

    • const jsreport = require('jsreport-browser-client-dist/jsreport');

    in the worst case you should have the jsreport available in window.jsreport if none of the above methods works



  • Can you point me to a working example. I couldn't get it to work. Still getting
    TypeError: Cannot set property 'serverUrl' of undefined


  • administrators

    i don't have a specific example that shows usage of browser-client-dist inside angular but using const jsreport = require('jsreport-browser-client-dist/jsreport'); seems to work

    live example that at least shows jsreport-browser-client-dist is defined in angular project: https://codesandbox.io/s/1rr3vkwxvj

    did you tried that?



  • thanks it worked


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.