-1
I need to save a form in the bank, with several fields input. Someone has an example of how to pass the fields. I am using the framework Angularjs (If I need to turn them into one array or use json Encode).
This is the part of view that contains the form. Doubt is how to send preco1
and nome1
to the database. The parameter file and configuration is Ok
<script>
angular.module("slimApp", []);
angular.module("slimApp").controller("slimAppController", function($scope, $http){
$scope.app = "Slim Produtos";
$scope.adicionarProduto = function(produtos){
$http.post('http://localhost/SlimProjeto/RestProdutos/produtos', {nome1:'', preco1:''}).
success(function(data, status, headers, config) {
}).
error(function(data, status, headers, config) {
});
};
});
</script>
</head>
<body ng-controller="slimAppController">
<div class="jumbotron">
<h3>{{app}}</h3>
<form class="form-control" method="post" id="form">
<input type="text" id="nome1" name="nome1"/>
<input type="text" id="preco1" name="preco1"/>
<button class="btn btn-block btn-primary" ng-click="adicionarProduto(form)" >Adicionar Produto</button>
</form>
</div>
instead of sending each object item, send the whole object.
– Ivan Ferrer
Here is an example: http://answall.com/questions/82975/databasecom-angularjs-e-php-n%C3%A3o-funciona/83162#83162
– Ivan Ferrer