Created
February 20, 2015 18:16
-
-
Save BarryFogarty/254ff2e61cca05f43411 to your computer and use it in GitHub Desktop.
Merchello.Plugin.Payments.SagePay: ng-Controller for provider settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('merchello.plugins.sagepay').controller('Merchello.Plugin.Payment.SagePayPaymentProviderController', | |
['$scope', | |
function ($scope) { | |
console.info($scope.dialogData); | |
if ($scope.dialogData.provider.extendedData.items.length > 0) { | |
var extendedDataKey = 'merchSagePayProviderSettings'; | |
var settingsString = $scope.dialogData.provider.extendedData.getValue(extendedDataKey); | |
$scope.sagePayProviderSettings = angular.fromJson(settingsString); | |
console.info($scope.dialogData); | |
console.info($scope.sagePayProviderSettings); | |
// Watch with object equality to convert back to a string for the submit() call on the Save button | |
$scope.$watch(function () { | |
return $scope.sagePayProviderSettings; | |
}, function (newValue, oldValue) { | |
console.info(newValue); | |
$scope.dialogData.provider.extendedData.setValue(extendedDataKey, angular.toJson(newValue)); | |
}, true); | |
} | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What value is in the database before the dialog is opened?