业务场景:购买次数输入框和预警次数输入框。要求预警次数小于购买次数。当超过的时候需要文字提示。
解决办法:写一个方法
validateBiggerBuyTimesAndWarinTimes() {
if (!this.productForm.value.xxx) {
return true;
}
if (this.productForm.value.yyy&& this.productForm.value.xxx) {
if (Number(this.productForm.value.xxx) <= Number(this.productForm.value.yyy)) {
return false;
} else {
return true;
}
} else {
return;
}
}
显示文字标签:
<div class="warn-message" [hidden]="validateBiggerBuyTimesAndWarinTimes()">请输入balabalabal</div>