0

I am using PDFSharp in my project. I need to open a modal after it saves the document. The function to open the modal is in a Angular controller. How would I do this?

WebApi Controller

 // Save the document...
           const string filename = @"C:\Users\texas_000\Desktop\TexasExterior\TexasExterior\JobSetupPdfs\HelloWorld.pdf";

            document.Save(filename);
            // ...and start a viewer.
           // Process.Start(filename);
        }
        catch (Exception ex)
        {
            Debug.Print(ex.ToString());
        }
        return string.Empty;

Function to open Modal

$scope.PrintPreviewModal = function () {
    $ekathuwa.modal({
        id: "PrintPreviewModal", contentStyle: "width:800px;heigth:400px",
        scope: $scope,
        templateURL: "ModalPrintPreview"
    });
}

2 Answers 2

1

I'm assuming you know how to make API calls from your angular app.

After you make your api call and it returns, you want to execute $scope.PrintPreviewModal()

If you are using promises you will want to do this in the Success function that is executed when you get a 200 response code back. I hope this helps.

 $scope.save = function () {
        save(params, success, error); //api call to save doc
    };

    var success = function () {
       $scope.PrintPreviewModal(); //open modal
    };

    var error = function () {
      //do something
    };
Sign up to request clarification or add additional context in comments.

Comments

0

I don't know exactly how you're calling off to the WebApi controller, but I'd imagine (since you're using Angular) you're using Angular's $http service.

If so, just open the modal on the promise success at the end of the call:

$http.get('/SaveTheDocumentWebApiAction').success(function (){
    $scope.PrintPreviewModal();
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.