我正在尝试从密码字段中获取值并在我的代码中使用它, 这是使用
的html部分<input type="password" maxlength="50" placeholder="Password"
required [(ngModel)]="resetModel.password" name="password" required #password="ngModel">
<input type="password" maxlength="50" placeholder="Confirm Password"
required [(ngModel)]="resetModel.confirmPassword" name="confirmPassword" required #confirmPassword="ngModel">
nowI've已经在component.ts文件中初始化了这个resetModel对象
constructor(
public resetModel: Reset) { }
我有一个带有这些参数的Reset类,
export class Reset {
public password: string;
public confirmPassword: string;
constructor() {
this.password = '';
this.confirmPassword = '';
}
}
但是当我尝试加载网页时,会显示以下错误
错误错误:未捕获(在承诺中):错误:模板解析错误: 将“exportAs”设置为“ngModel”(“holder =”Password“)没有指令 required [(ngModel)] =“resetModel.password”name =“password”required [ERROR - &gt;] #password =“ngModel”&gt; “):ng:///ResetPasswordModule/ResetPasswordComponent.html@30:82 无法绑定到'ngModel',因为它不是'input'的已知属性。 (maxlength =“50”占位符=“密码” 必需[错误 - &gt;] [(ngModel)] =“resetModel.password”name =“password”required#password =“ngModel”&gt;