I am trying to automate the sending of a form via Angular and bind the input values with variables in my controller. For some reason however, these values are not being recognised.
<ion-view cache-view="false" ng-controller="CashierController as cashCtrl" class="background">
<ion-nav-title></ion-nav-title>
<ion-content padding="true">
<form id="cashier" name="cashCtrl.cashierForm" method="POST" action="https://url.action" target="screen">
<input type='hidden' id='token' name='token' ng-model="cashCtrl.token" />
<input type='hidden' id='merchantId' name='merchantId' ng-model="cashCtrl.merchantId" />
<input type='hidden' id='customerId' name='customerId' ng-model="cashCtrl.customerId" />
<input type='hidden' id='action' name='action' ng-model="cashCtrl.action" />
<input type='hidden' id='paysolName' name='paysolName' ng-model="cashCtrl.paysolName" />
</form>
<iframe name="screen" height=600 width=320>
</iframe>
</ion-content>
</ion-view>
Now, on the controller I am specifying them as follows:
var app = angular.module('app');
app.controller('CashierController', function($scope, $state, $window, $localStorage, GatewayService) {
var self = this;
this.cashierUrl = "https://url.action";
this.token = $localStorage.cashierToken;
this.merchantId = '//';
this.customerId = $localStorage.customerId;
this.action = '//';
this.paysolName = 'CreditDebitCards';
console.log(this.cashierForm);
document.getElementById('cashier').submit();
this.goToPage = function(page) {
$state.go(page);
}
})
Worth noting is that if I specify the variables using curly bracket notation like so: {{cashCtrl.token}}
BUT not on the form, the binded values do show. Furthermore, the line console.log(this.cashierForm);
returns undefined
.
What am I doing wrong?