Dears, 

I'm trying to make a form with fields with dynamic names, so because the 
number of fields depends on each record coming from the database ...

However, I always try to retrieve the value of what was typed not INPUT of 
the form the console only displays the undefined value.

Follow the code with simplified example of what I'm trying to do:

In My Controller:
  var CONTROLLER = [...., function (.......) {

    $scope.lista = [{ name:'test' , placeholder:'Only test' },{ name:
'test_2' , placeholder:'Only test 2' }];
    
    $scope.testacampos = function() {
        console.log("Field 1: "+$scope.teste);
        console.log("Field 2: "+$scope.test_2);
      };
  }];
    angular.module(CONSTANTS.APP).controller('EditarFormCtrl', CONTROLLER);

})();


In my Html:
<div class="row" ng-controller="EditarFormCtrl">
    <div class="col-md-12">
        <div class="caixa">
            <h5>TESTE </small></h5>
                            <div data-ng-repeat="campos in lista">
                                  <div data-ng-switch="campos.type">
                                             {{campos.name}}
                                           <input type="text" ng-model=
"form[campos.name]" />
                                  </div>
                            </div>
    </div>
</div>

<div class="row">
    <div class="col-md-12">
        <div class="caixa">
                  <button type="button" class="btn btn-sm btn-success" 
ng-click="testacampos()">Testar</button>
    </div>
</div>



If I assign a value inside the controller to the field, the value is 
printed on the console. But when the value is entered in the HTML form 
nothing is printed on the console.

Output on the console when you press the button to test the form:

Field 1: undefined
Field 2: undefined

Thanks for all the help!

-- 
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.

Reply via email to