How to display jsreport response into browser using angularjs?



  • I'm trying to integrate jsreport with angularjs project. I can post jsreport json data but don't know to display that response into browser .Anyone tell me how to render jsreport from the response .Below is my angularjs controller code.

    .controller('View1Ctrl', [ '$scope', '$http',function($scope, $http) {
    var onSuccess = function (data, status, headers, config) {
              $scope.data = data;
          };
          var onError = function (data, status, headers, config) {
              $scope.error = status;
          }
          var datajson = {
           template:{'shortid':'S1Auk01mb'},
       }
          var postReq = {
                  method: 'POST',
                  url: 'http://localhost:8005/api/report',
                  data:datajson
              };
          $http(postReq).success(onSuccess).error(onError);
    
          var getReq = {
                   method: 'GET',
                   url: 'http://localhost:8005/studio/templates/S1Auk01mb'
               };
           $http(getReq).success(onSuccess).error(onError);
           $http(getReq)
           .then(response => {
             console.log(response.data);
           })
           .catch(errorpayload => {
             console.log(errorpayload.data);
           });
    }]);
    

    Html code:

    <div ng-controller="View1Ctrl">
            Response: {{data}} <br/>
    	Error: {{error}}
    </div>

  • administrators

    hi! you can take a look how we handle the response here, which you can adapt it to angular code.



  • Thank you so much for your reply @bjrmatos



  • Hello @Purushoth11

    Have you succeeded in implementing the Jsreport with the Angularjs? If so, is it possible to show how it was done?

    I really appreciate the help.


Log in to reply
 

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