On one occasion, we were developing a form here in the company where, when selecting a product through an Autocomplete, the ID of that product was stored in a input hidden
.
I noticed that AngularJS was not capturing the value of this input hidden, in which it was necessary to know id
of the selected product.
Autocomplete was developed using jQuery
, which inserts the value in the input hidden by val()
.
So:
$('#produto_id').val($(this).data('id'));
In the Angular JS we have this code:
<input type='hidden' ng-model="entrada.produto_id" id="produto_id">
However, when calling the function salvar
with ng-submit
, the value of entrada.produto_id
does not appear, but only the other fields.
We found that it was necessary to have jQuery make a trigger('input')
by entering the value in #produto_id
. But it still did not work. But everything worked correctly when we replaced hidden
with text
(with display:none
);
Comment : First of all, before asking the question, I would like to point out that the intent of this question is not to know how to circumvent this situation , since, as mentioned above, already we resolve.
I would just like to know if it's an official statement to say that AngularJS
does not read hidden inputs.