5
The fields itemCodigo, itemDescription, itemPreco and itemQuantidade are filled dynamically (at runtime, without refresh) from a query performed in the database. However, these values, when passed as parameter to the addItem() function, return undefined, that is, when clicking the "Insert" button, the fields that should be "cloned" to the table [Code | Description | Price | Quantity] are empty.
Illustration:
HTML:
<div ng-app="app" ng-controller="controlador">
<input type="text" name="busca" placeholder="Pesquisar produto"/>
<br /><br />
<input type="button" value="Inserir" id="inserir-item" ng-click="addItem(itemCodigo, itemDescricao, itemPreco, itemQuantidade)"/>
<br /><br />
<input type="text" id="codigo" readonly ng-model="itemCodigo">
<input type="text" id="descricao" readonly ng-model="itemDescricao">
<input type="text" id="preco" readonly ng-model="itemDescricao">
<br /><br />
<td>{{item.codigo}}</td>
<td>{{item.descricao}}</td>
<td>{{item.preco}}</td>
<td>{{item.quantidade}}</td>
</div>
Javascript:
var app = angular.module('app', []);
app.controller("controlador", function($scope){
$scope.addItem = function (itemCodigo, itemDescricao, itemPreco, itemQuantidade) {
$scope.items.push({
codigo: itemCodigo,
descricao: itemDescricao,
preco: itemPreco,
quantidade, itemQuantidade
});
};
})
Note: itemQuance, is set in another input within the code.


where your $Scope array.items????
– fernandoocf
$Scope items. = [];
– lucasbento