嗨,我正在尝试创建一个新用户,这个语法不起作用,它说'用户'只引用一个类型,但在这里被用作值.
onSubmit() {
if (this.userForm.valid) {
let user: User = new User(null,
this.userForm.controls['cin'].value,
this.userForm.controls['familyName'].value,
this.userForm.controls['givenName'].value,
this.userForm.controls['email'].value,
this.userForm.controls['description'].value,
this.userForm.controls['code'].value);
this.adminService.createUser(user).subscribe();
}
}Run Code Online (Sandbox Code Playgroud)
export interface User {
cin: string;
givenName: string;
familyName: string;
role: string;
id: string;
email: string;
}Run Code Online (Sandbox Code Playgroud)
这是因为User被声明为接口?我怎么解决它?提前致谢 :)