Hi,
i want to try some coding with angularjs.
I need to compile a input tag with some numeric data and when what i've
inserted is in a field in a table, my app returning relative data.
Eg.
Table Product: two field -> Barcode (primary key) and Description (textual)
12345 - descr1
23456 - descr2
I want that if i've compiled first input tag with 12345, in the second
input tag is displayed "descr1" dinamically.
I've tried this:
...include angularjs file...
<script>
var mag = angular
.module('magInOut', []);
.controller('ins', ['$scope', '$http', function ($scope, $http) {
$http.get("product.php", {params:{barcode:$scope.barcode}})
.success(function(data){
$scope.data = data;
})
.error(function() {
$scope.data = "error in fetching data";
});
}]);
</script>
</head>
<body ng-app="magInOut">
<div ng-controller="ins">
<input type="text" name="barcode" />
<input type="text" value="{{ data.Description }}" />
</div>
</body>
This is product.php file:
... connecting database
<?
$barcode = $_REQUEST['barcode'];
$query = "SELECT Description FROM products WHERE Barcode = :barcode"
;
if($stmt = $connection->prepare($query)){
$stmt->bindValue(':barcode', $barcode, PDO::PARAM_INT);
$stmt->execute();
$arrayResult = $stmt->fetch(PDO::FETCH_ASSOC);
$data[] = $arrayResult;
}
print json_encode($data);
?>
I don't know how to pass barcode variable into php page without do a form.
It is possible?
Thank you
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.