resetForm

This commit is contained in:
2016-04-10 13:51:00 +02:00
parent 832fa6635e
commit 8ee714a060
6 changed files with 37 additions and 13 deletions
+18 -5
View File
@@ -6,6 +6,19 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
console.log('refreshList()');
// reset form
if ($scope.form) {
$scope.form.$setPristine();
$scope.form.$setUntouched();
}
$scope.transaction = {
amount: 1,
date: new Date(),
// category: categories._embedded.categories[0]
};
// get recent transactions
var transactions = $resource('/transactions/search/last10', { accountId: $scope.accountId }).get();
transactions.$promise.then(function(data) {
@@ -27,7 +40,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
console.log('initList()');
$scope.date = new Date();
//$scope.transaction.date = new Date();
$scope.refreshList();
@@ -37,7 +50,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
$scope.categories = categories._embedded.categories;
// select the first entry as default
$scope.category = categories._embedded.categories[0];
$scope.transaction.category = categories._embedded.categories[0];
});
}
@@ -49,9 +62,9 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
var newTransaction = new Transaction({
"account" : $scope.account,
"amount" : $scope.amount,
"date" : $scope.date,
"description" : $scope.description,
"amount" : $scope.transaction.amount,
"date" : $scope.transaction.date,
"description" : $scope.transaction.description,
"category" : $scope.category._links.self.href,
"creditor" : $scope.creditor
});