How to pass value dynamically changed to function, in AngularJS

The itemCodigo and itemDescricao fields are populated dynamically (at run time, without refresh) from a query performed in the DB. However, these values, within the addItem() function, return undefined.



<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)"/>
       <br /><br />
       <input type="text" id="codigo" readonly ng-value="itemCodigo" ng-model="itemCodigo">
       <input type="text" id="descricao" readonly ng-value="ttl" ng-model="itemDescricao">
       <br /><br />


var app = angular.module('app', []);

app.controller("controlador", function($scope){
    $scope.addItem = function (itemCodigo, itemDescricao) {
                  codigo: itemCodigo,
                  descricao: itemDescricao

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.