Radio Button

참조

app.module.ts

import {MatRadioModule} from '@angular/material/radio';

@NgModule({
  imports: [MatRadioModule]
})

예제 1

  • template
<mat-radio-group (change)="onChangeDifficulty($event)">
   <input id="difficulty-easy" type="radio" name="difficulty" value="0"  [checked]="difficulty == '0'"><label for="difficulty-easy">Easy</label>
   <input id="difficulty-normal" type="radio" name="difficulty" value="1"   [checked]="difficulty == '1"><label for="difficulty-normal"> Normal</label>
   <input id="difficulty-hard" type="radio" name="difficulty" value="2"  [checked]="difficulty == '2'"><label for="difficulty-hard"> Hard</label>
</mat-radio-group>
  • component
public onChangeDifficulty(e: any) {
  console.log('e.target.value);
}

Table of contents 목차

평점을 남겨주세요
평점 : 2.5
총 투표수 : 1