app.controller('parametriCtrl',
	
function ($scope,$http,$cookies,$window, $location,$timeout, $mdDialog, $q, utilsSvc, AppParam) {
	
	var vm=this;

	vm.params=null;
	vm.getParams = function() {
		AppParam.Get().$promise.then(
				function(data){
					vm.params = data;
				},
				function (err){
					utilsSvc.handleHttpError(err);		
				}
		);
	}
	
	vm.setParams = function(){
		if ($scope.form.$valid)
			AppParam.Set(vm.params).$promise.then(
					function(data){
						utilsSvc.show('Configurazione salvata');
					},
					function (err){
						utilsSvc.handleHttpError(err);		
					}
			);
		else 
			utilsSvc.showMessage("Verificare i dati inseriti")
	}
	
	
	vm.getParams();
	
});