Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 重置角度9中的单选按钮状态_Angular_Radio Button_Material Design_Reset_Radio Group - Fatal编程技术网

Angular 重置角度9中的单选按钮状态

Angular 重置角度9中的单选按钮状态,angular,radio-button,material-design,reset,radio-group,Angular,Radio Button,Material Design,Reset,Radio Group,我正在使用Angular 9和mat单选按钮。我用来自服务器的数据填写用户passport。我想在接收数据时立即选择正确的单选按钮,所以我设置了双向绑定。单选按钮是可选择的。但是如果我打开另一个用户passport,那么在new passport单选按钮被选中,而在old passport中它完全消失——没有一个单选按钮被选中。所有其他用户数据保留在表单上。此外,在模型中,所有信息都会保存,当您选择单选按钮时,信息会更改。请告诉我,有什么问题吗 user.component.html Муж.

我正在使用Angular 9和mat单选按钮。我用来自服务器的数据填写用户passport。我想在接收数据时立即选择正确的单选按钮,所以我设置了双向绑定。单选按钮是可选择的。但是如果我打开另一个用户passport,那么在new passport单选按钮被选中,而在old passport中它完全消失——没有一个单选按钮被选中。所有其他用户数据保留在表单上。此外,在模型中,所有信息都会保存,当您选择单选按钮时,信息会更改。请告诉我,有什么问题吗

user.component.html


Муж.
Жен.
user.component.ts

从'@angular/core'导入{Component,OnInit};
从“../service/user.service”导入{UserService};
从“../../models/User/User”导入{User};
从“../../../home/home.component”导入{Data};
@组成部分({
选择器:“应用程序用户”,
templateUrl:“./user.component.html”,
样式URL:['./user.component.css']
})
导出类UserComponent实现OnInit{
公共用户:用户;
构造函数(数据:数据,私有用户服务:用户服务){
如果(数据!=未定义){
this.user=与用户一样未知的数据;
this.Get(this.user.id);
}
否则{
this.user=新用户();
}
}
ngOnInit():void{
}
私有Get(id:number){
this.userService.Get(id).subscribe(
data=>{this.user=(数据为任意数据).user为用户;}
);
}
}
user.ts

从“./doctors/Gender”导入{Gender};
导出类用户{
公众id:号码;
公共名称:字符串;
公众姓氏:string;
公共赞助人:字符串;
公共性别:性别;
公共登录:字符串;
公共密码哈希:字符串;
公众生日:日期;
公共就业日期INALPHA:日期;
构造函数(){
此参数为0.id;
this.name='';
this.姓氏=“”;
this.patronymic='';
this.gender=新性别();
this.login='';
this.passwordHash='';
this.birth=新日期();
this.employmentDateInAlpha=新日期();
}
}
gender.ts

导出类性别{
公众id:号码;
公共名称:字符串;
构造函数(){
这1.id=3;
this.name='khззааа';
}
}

我自己找到了这个问题的答案。我的
在里面

<mat-card>
   <form class = "example-form">
      ...
   </form>
</mat-card>

...
我用
替换了
,并从
中删除了
name=“gender”
,只有在这之后,绑定工作和单选按钮状态才停止重置。我不认为这会是一个问题