I am trying to adapt an angular contact form found here: http://www.chaosm.net/blog/2014/05/21/angularjs-contact-form-with-bootstrap-and-phpmailer/
It is working perfectly with regular text fields and I get all submitted data by PHP mailer. However, for a specific purpose I need to submit data from hidden input fields. For unknown reason it still works when I pass numeric value using two hidden inputs like this:
<input type="hidden" ng-model="pprice" ng-init="pprice=241.50" value="241.50" />
<input type="hidden" ng-model="formData.inputSubject" id="inputSubject" name="inputSubject" ng-init="formData.inputSubject = pprice" />
Unfortunately this method doesn't work with the text value or an angular expression from another controller - although the value attribute is being rendered correctly, the ng-init does not seem to take it:
<input type="hidden" ng-model="formData.inputSubject" value="{{post.title}}" ng-init="formData.inputSubject=post.title" />
Also none of other solutions I've found so far work: Bind hidden inputs to model in angular Angularjs assigning value to ng-model using ng-init
Why does ng-init accept only numerical values? Why the value attribute expression is not being passed to ng-init in the second case?
I would really appreciate some help as I've spent several hrs trying to resolve this...
You're almost there. String values in ng-init need quotes around them.
So that just means that:
ng-init="formData.inputSubject = pprice"
should become:
ng-init="formData.inputSubject = 'pprice'"