【发布时间】:2019-05-12 13:29:02
【问题描述】:
所以我有这个问题:
<form [formGroup]="myForm" >
<input autocomplete="off" type="text" name="number" formControlName="number" min="{{ FinalPaymentPrice}}"/> // This FinalPaymentPrice is a number which I get and whant to set. For example 2 and then 14 and so on
</form>
基于该 FinalPaymentPrice 数字,例如:4 个用户不允许输入 3 或更少,但允许输入 5 或更多。还有一个验证器:
export class PaymentComponent {
myForm = new FormGroup({
'number': new FormControl(null, [
Validators.required
])
});
问题是我的最小输入是可变参数。这个想法是你得到一些价格,你不能只输入更高的价格。所以如果我确实喜欢这个功能,但那是不对的。
export class PaymentComponent {
myForm = new FormGroup({
'number': new FormControl(null, [
Validators.required,
Validators.min(2)
])
});
我对 Angular 很陌生
【问题讨论】:
-
如果您使用表单控件不在信号引用中,我认为您在“数字”是字符串上犯了错误
-
这是故意的,因为它添加了货币和其他符号
标签: angular forms typescript input min