我有一个 angular 表单,我想在 html 输入标签中使用表单“Validators.minLength”的值。
我想知道是任何直接从 html 中的表单验证器使用的方法;
样本:
[maxLength]="form.get('zipCode').validators('maxLength)"
我的 ts 代码是:
zipCode: [ '', [
Validators.required,
Validators.maxLength(10),
number,
],
和 html 是: <input type="tel"
formControlName="zipCode"
[maxLength]="10" // here I want insert dynamic number from ts file
placeholder="insert your zip code">
坦克为您提供帮助。
最佳答案
TS
this.maxLength=10;
zipCode: [ '', [
Validators.required,
Validators.maxLength(this.maxLength),
number,
],
HTML<input type="tel" formControlName="zipCode" placeholder="insert your zip code">
关于angular - 如何获取表单输入的 Validators.minLength 并在 html 中动态设置它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64350781/