【发布时间】:2017-12-04 11:34:45
【问题描述】:
我想在我的输入中添加禁用消息选项
我向你解释我有一些与相关消息相关的规则,如果用户在她的输入中点击 disableMessage,我想要
消息不显示我认为需要使用布尔条件但我不知道如何
我的代码:
@Input () ValidationHints: any
ngOnInit() {
this.required = this.required !== undefined && this.required !== false
this.disabled = this.disabled !== undefined && this.disabled !== false
this.readonly = this.readonly !== undefined && this.readonly !== false
this.ngModelRef = ''
this.ValidationHints = {
required: 'This field is required.',
minlength: 'Field must be at least ' + this.minlength + ' characters long.',
maxlength: 'Field cannot be more than ' + this.maxlength + ' characters long.',
pattern: 'Please match the requested format.'
}
}
和html输入:
<mae-input type="text"
minlength="3"
maxlength="10"
pattern="[a-z]+"
[withCharCount]="true"
[(ngModel)]="input"
required
>
</mae-input>
谢谢 ;)
【问题讨论】:
标签: angular validation input