如果用户输入输入disabledMessages

时间:2017-06-30 13:25:22

标签: angular validation input

我想在输入中添加禁用消息选项

我向你解释我有一些关联消息的规则,如果用户在她的输入中点击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>

谢谢;)

1 个答案:

答案 0 :(得分:1)

您可以使用指令* ngIf =&#34; enableMessage&#34;或[禁用] =&#34;禁用&#34;