angularjs - Download pdf file on client side -


i beginner mean stack. want download , display pdf file client. server side script under:

app.get("/pdf", function(req, res)     {         var file = __dirname + '/try.pdf';         res.download(file, function (err)              {                if (err) {                    console.log("error " + err);                } else {                    console.log("success");  // server shows success file not downloaded client                 }                res.end();             }         );     } ); 

after starting server when give command localhost/pdf in browser file downloaded. but, when connect server through index page , attach module ng-click event of button, server shows success file not downloaded client. angularjs code under displays both success , clause message:

        app.controller('showpdf', function($scope, $http)             {                 $scope.pdfshow = function()                 {                     alert("inside pdfshow");                      $http.get("/pdf" ).                     success(function(response){alert("pdf success")}).                     error(function(error, status){alert("pdf error " + error + " status " + status); }).                     then(function(response){alert("pdf clause ")})                 }              }         );           <button ng-controller="showpdf" ng-click="pdfshow()">show pdf file </button> 

is there mistake doing? please guide me.

thanks.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -