Issue
<div class="container">
<div class="row">
<form>
<div class="form-group">
<label>username</label>
<br />
<input type="text" class="form-control" />
</div>
<div class="form-group">
<label>email</label>
<br />
<input type="email" class="form-control" />
</div>
<div class="form-group">
<label>secret question</label>
<br />
<select type="radio" class="form-control">
<option value="pet">your fav. pet?</option>
<option value="teacher">your fav. teacher?</option>
</select>
</div>
<div class="form-group">
<textarea cols="60" rows="5"></textarea>
</div>
<div>
<p style="margin: 10px">your reply:</p>
</div>
<div class="radio" *ngFor ="let gender of genders">
<label> <input type="radio" [value]="gender" />{{ gender }} </label>
</div>
<button type="submit" style="margin-left: 10px">submit</button>
</form>
</div>
</div>
here in div class="radio" I am passing a string array which contains 2 value 'male' and 'female'. Expected behavior should be once male selected female should get UN-selected and vice versa. But I don't know why I am able to select both male and female radio button.
Thanks in advance
Solution
You have to add an attribute name on your input
<input type="radio" [value]="gender" name="gender" />{{ gender }}
Answered By - FolabiAhn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.