How get checked value from radio button angular

前端 未结 1 1556
时光取名叫无心
时光取名叫无心 2021-02-14 22:52

I need to get value from radio button in angular. Suppose to have this html code:

 
相关标签:
1条回答
  • 2021-02-14 23:11

    You can bind the data of radio button. Just add the value for radio button and change in the ngModel

    html

    <input class="form-check-input" type="radio" value="dog" 
    [(ngModel)]="dog.value" name="gob" value="i" [checked]="true" 
    (change)="onItemChange($event.target.value)"/>
    

    ts

    onItemChange(value){
       console.log(" Value is : ", value );
    }
    
    0 讨论(0)
提交回复
热议问题