javascript - AngularJS does not send hidden field value -


for specific use case have submit single form "old way". means, use form action="". response streamed, not reloading page. aware typical angularjs app not submit form way, far have no other choice.

that said, tried populate hidden fields angular:

<input type="hidden" name="somedata" ng-model="data" /> {{data}} 

please note, correct value in data shown.

the form looks standard form:

<form id="aaa" name="aaa" action="/reports/aaa.html" method="post"> ... <input type="submit" value="export" /> </form> 

if hit submit, no value sent server. if change input field type "text" works expected. assumption hidden field not populated, while text field shown due two-way-binding.

any ideas how can submit hidden field populated angularjs?

you cannot use double binding hidden field. solution use brackets :

<input type="hidden" name="somedata" value="{{data}}" /> {{data}} 

edit : see thread on github : https://github.com/angular/angular.js/pull/2574

edit:

since angular 1.2, can use 'ng-value' directive bind expression value attribute of input. directive should used input radio or checkbox works hidden input.

here solution using ng-value:

<input type="hidden" name="somedata" ng-value="data" /> 

here fiddle using ng-value hidden input: http://jsfiddle.net/6sd9n


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -