I'm having trouble passing data from my AngularJS controller on my Visualforce page to the Apex Controller.
I've created an actionFunction on the VF page:
<apex:form>
<apex:actionFunction action="{!exportToPdf}" name="exportToPdf">
<apex:param name="firstParam" assignTo="{!productData}" value=""/>
<apex:param name="secondParam" assignTo="{!calculatedProductData}" value=""/>
</apex:actionFunction>
</apex:form>
Then from within my AngularJS controller I do the following:
$scope.exportToPdf = function() {
var productData = JSON.stringify($scope.productData);
var calculatedProductData = JSON.stringify($scope.calculatedProductData);
window.alert(productData);
exportToPdf(productData, calculatedProductData);
};
The $scope.exportToPdf()
is then executed when a user clicks a button on the Visualforce page:
<div class="slds-col slds-no-flex slds-grid slds-align-bottom">
<button class="slds-button slds-button--neutral" ng-click="exportToPdf()">
Export To PDF
</button>
</div>
Apex Controller:
public with sharing class InvoiceCalculatorController {
public String productData { get; set; }
public String calculatedProductData { get; set; }
public PageReference exportToPdf() {
system.debug('PDATA:' + this.productData);
system.debug('CALCDATA:' + this.calculatedProductData);
PageReference printView = Page.InvoiceCalculatorPrintView;
return printView;
}
}
The end result is productData
and calculatedProductData
are both null in the system.debug statement.
Any ideas on what's going on here?