I am trying to create a survey. The code looks like this:
<form ng-submit="passEngineer(engineer)">
<input type="radio" ng-model="engineer" ng-required="!engineer">Default
<input type="radio" ng-model="engineer" ng-required="!engineer">Custom
<input type="text" ng-model="engineer" ng-required="!engineer">
</form>
If First
selected, it DOES pass it without issues. If Second
selected, it SHOULD pass the value entered inside third
input. How can I do that? Value in third input MUST be passed if second input selected. Tried many ways, can't really figure out.
I think you need to divide up how you're applying ng-model
. You might make engineer
an object in your controller and then change your markup like this:
<form ng-submit="passEngineer(engineer)">
<input name="engineer" type="radio" ng-model="engineer.isDefault">Default
<input name="engineer" type="radio" ng-model="engineer.isCustom">Custom
<input type="text" ng-model="engineer.customValue" ng-required="engineer.isCustom">
</form>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.