ts:
budget = new FormControl(null, [Validators.required]);
html:
<input
id="budget"
currencyMask
placeholder="Dollar"
[ngModel]="modelService.budget"
[formControl]="budget"
value="{{ modelService.budget}}"
[min]="1.0"
[options]="{decimal: ',', thousands: '.', allowNegative: false }"
type="text"
/>
規格:
it('should not valid', fakeAsync(() => {
component.ngOnInit();
component.budget.setValue(0);
tick();
fixture.detectChanges();
expect(component.budget.valid).toBe(false);
}));
我的測驗總是正確的。我怎樣才能將我的預算值和控制權修補到我的有效值。0 -> 應該無效 10 -> 應該有效
uj5u.com熱心網友回復:
input 元素上的 min 屬性不會使 FormControl 無效。請添加最小驗證器。
budget = new FormControl(null, [Validators.required, Validators.min(1.0)]);
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/516435.html
