Angular 2单选按钮ngmodel

时间:2019-03-27 14:58:09

标签: angular6 angular5 angular2-forms

单选按钮验证在angular 2中无法正常工作。我尝试过,但是我不知道如何使用ng-model。任何人都可以解决此问题?

  <div *ngIf="f.submitted && radio.invalid">
 Please check any one
 </div>

   <form #f="ngForm">
<div *ngFor="let option of options">
    <div class="radio">
        <input type="radio"
           name="radio"
           id="radio-{{option.id}}"
           [(ngModel)]="value"
           [value]="option.value"
           #radio="ngModel"
           />

    <label for="radio-{{option.id}}">{{option.id}}
    </label>

 </div>
 </div>
 <button>Submit</button>
 </form>

0 个答案:

没有答案