为什么我的单选按钮会被自动选中?如何在Angular9中默认只发送一个?

Why my Radio buttons are checked automatically? How can I send only one by default in Angular 9?

我现在的问题是我有两个radio-button,我想要的是当你点击admin单选按钮时你可以查看一个表单,当您单击 user 单选按钮时,您可以看到另一个表单。到现在都勾选了,不知道为什么,只想默认勾选一个,一次显示一个表格

单选按钮的 html

<mat-radio-group aria-label="Select an option" class="center">
    <mat-radio-button  (click)="radio_btn=true" >Admin</mat-radio-button>
    <mat-radio-button (click)="radio_btn=false">User</mat-radio-button>
  </mat-radio-group>
  <div class="ng-container ">
        <div class="row justify-content-center" *ngIf="radio_btn==true">
        <form class="example-form " [formGroup]="signupForm" (ngSubmit)="send(signupForm)">
          <mat-form-field class="example-full-width">
            <input matInput formControlName="email" placeholder="User" type="email">
          </mat-form-field><br>
          <div *ngIf="signupForm.get('email').hasError('email') && signupForm.get('email').touched">Introduce an email</div><br>
          <mat-form-field class="example-full-width">
            <input matInput formControlName="password" placeholder="Password" type="password">
          </mat-form-field><br>
          <div *ngIf="signupForm.get('password').hasError('password') && signupForm.get('password').touched">Introduce the correctly password</div><br>
          <button mat-raised-button [disabled]="signupForm.invalid" class="colour_button " type="submit">Register</button>
        </form>
    </div>
</div>

电台的TS文件

export class HomeComponent implements OnInit {
  radio_btn:boolean = true;
  ngOnInit(): void {
  }
}

他们长这样

将此放入您的广播组:

<mat-radio-group [(ngModel)]="radio_btn”

然后有

<mat-radio-button [value]=“true“

    <mat-radio-button [value]=“false”

同时从单选按钮中删除(单击)处理程序。

更改 radio_btn 值。

参见 Material radio example html