-
-
Save anonymous/ee36d253a9f9b80b1eba7e8a0bc16872 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
'use strict'; | |
App.controller('PoController', ['$scope', 'PoService', function($scope, PoService) { | |
var vm = this; | |
vm.order = {id: null, status: null, item:null , plannedQty: null, plannedDate: '', description:''}; | |
vm.orders = []; | |
vm.fetchAllOrders = function () { | |
PoService.fetchAllOrders() | |
.then( | |
function (d) { | |
vm.orders = d; | |
}, | |
function (errResp) { | |
console.error('Error while fetching production orders!'); | |
} | |
); | |
}; | |
vm.createOrder = function (item) { | |
PoService.createOrder(item) | |
.then( | |
vm.fetchAllOrders, | |
function (errResponse) { | |
console.error('Error while creating production order'); | |
} | |
); | |
}; | |
vm.fetchAllOrders(); | |
vm.submit = function () { | |
if (vm.order.id === null) { | |
console.log('Saving new order', vm.order); | |
vm.createOrder(vm.order); | |
} else { | |
console.log('Sth wrong with adding new order'); | |
} | |
vm.reset(); | |
}; | |
vm.reset = function () { | |
vm.order = {id: null, status:null, item: null, plannedQty: null, plannedDate: '', description:''}; | |
$scope.myForm.$setPristine(); | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment