我正在尝试通过temmplate驱动来验证角度2中的单选按钮,但不能正常工作。我在Google中搜索过,也没有人回答正确。任何天才都可以回答这个问题?
https://stackblitz.com/edit/angular-zpyekb?file=src/app/app.component.html
app.component.html
archive.pipe(stream)
答案 0 :(得分:0)
<div *ngFor="let option of options">
<div class="radio">
<input type="radio"
name="radio"
id="radio-{{option.id}}"
[(ngModel)]="value"
[value]="option.value"
required
/>
<label for="radio-{{option.id}}">{{option.id}}
</label>
</div>
</div>
<div *ngIf="f.submitted && !f.valid">Please select</div>
May be you are looking for the above validation. If not can you please help to know what exactly you are looking for ?