【问题标题】:disabled my message on input if the user enter in the input disabledMessages如果用户输入输入禁用消息,则禁用我的输入消息
【发布时间】: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


    【解决方案1】:

    您可以使用指令 *ngIf="en​​ableMessage" 或 [disabled]="disabled"

    【讨论】:

    • 禁用我的输入而不是我的验证消息
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    • 1970-01-01
    • 2018-09-02
    • 2011-05-24
    • 2017-05-12
    • 1970-01-01
    • 2019-06-01
    相关资源
    最近更新 更多