Created
November 5, 2014 21:18
-
-
Save InstyleVII/ec652da3a81c2504fc8c to your computer and use it in GitHub Desktop.
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
// Parent Controller | |
angular.module('CsWebApp.PayYourBill', []) | |
.controller('PayYourBillController', [ | |
'$scope', '$http', function ($scope, $http) { | |
$scope.test = 'true'; | |
} | |
]); | |
// Child Controller | |
angular.module('CsWebApp.PayYourBill.Form', []) | |
.controller('FormController', [ | |
'$http', '$location', '$anchorScroll', function ($http, $location, $anchorScroll) { | |
var formModel = this; | |
this.load = function () { | |
$(function () { | |
applyClassnames(); | |
triggerPlugins(); | |
}); | |
} | |
this.load(); | |
// Reset the scroll to the top of the view | |
this.goToTop = function () { | |
$location.hash('top'); | |
$anchorScroll(); | |
} | |
this.goToTop(); | |
this.oneTime = 'true'; | |
this.differentAccount = 'false'; | |
console.log(this.test); | |
console.log(this.$parent); | |
console.log(this.parent); | |
console.log(formModel.$parent); | |
// GET Model | |
$http.get('/Payment/PayYourBill/GetModel').success(function (viewModel) { | |
if (viewModel['AccountData'].length > 0) { | |
formModel.viewModel = viewModel; | |
formModel.accounts = [ | |
{ label: viewModel['AccountData'][0].AccountLabel, value: 0 } | |
]; | |
for (var i = 1; i < viewModel['AccountData'].length; i++) { | |
formModel.accounts.push({ label: viewModel['AccountData'][i].AccountLabel, value: i }); | |
} | |
formModel.selectedAccount = formModel.accounts[0]; | |
formModel.setScope(0); | |
} | |
}); | |
// Form Process | |
this.update = function () { | |
this.setScope(this.selectedAccount.value); | |
} | |
this.setScope = function (index) { | |
this.accountNumber = this.viewModel['AccountData'][index].AccountNumber; | |
this.serviceAddress = this.viewModel['AccountData'][index].ServiceAddress; | |
this.serviceAddressTwo = this.viewModel['AccountData'][index].ServiceAddress2; | |
this.firstName = this.viewModel['AccountData'][index].FirstName; | |
this.middleInitial = this.viewModel['AccountData'][index].MiddleInitial; | |
this.lastName = this.viewModel['AccountData'][index].LastName; | |
this.routingNumber = this.viewModel['AccountData'][index].RoutingNumber; | |
this.bankAccountNumber = this.viewModel['AccountData'][index].BankAccountNumber; | |
this.accountLabel = this.viewModel['AccountData'][index].AccountLabel; | |
if (this.bankAccountNumber === '' || this.routingNumber === '') { | |
this.differentAccount = 'true'; | |
this.hasAccount = 'false'; | |
} else { | |
this.hasAccount = 'true'; | |
} | |
//force a default for now | |
this.paymentAmount = '25.00'; | |
} | |
this.multipleAccounts = function () { | |
if (this.viewModel) { | |
return this.viewModel['AccountData'].length > 1; | |
} | |
return false; | |
} | |
this.determineRoute = function () { | |
this.$parent.postBankAccountNumber = this.bankAccountNumber; | |
this.$parent.postRoutingNumber = this.routingNumber; | |
if (this.oneTime === 'true') { | |
this.$parent.formType = '#/OneTime'; | |
} else { | |
this.$parent.formType = '#/Automatic'; | |
} | |
} | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment