替换输入

时间:2017-06-29 07:44:56

标签: angular input

你好我需要在输入中替换消息默认

这是我的input.component:

@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.'

    }
  }

我想要的时候如果我这样写输入:

 <mae-input type="text"
           minlength="3"
           maxlength="10"
           pattern="[a-z]+"
           [withCharCount]="true"
           [(ngModel)]="input"
           required
>
</mae-input>

我想添加类似ValidationHints="{required :'my new message'}"

的内容

我知道语法不好但谁可以有这样的东西?

感谢

1 个答案:

答案 0 :(得分:0)

在你的html中尝试[ValidationHints] = "{required :'my new message'}",就像这样;

<mae-input [ValidationHints] = "{required :'my new message'}"></mae-input>

详细了解@input binding here