【问题标题】:How to Limit the characters size of chip of angular-material mat chips?如何限制角料垫芯片的字符大小?
【发布时间】:2020-03-14 17:38:35
【问题描述】:

我正在使用 Angular 材质 mat-chips 来实现标签的管理功能。当我使用 maxLength 验证器属性时,它正在检查芯片的数量,即标签的数量。 但我想在客户输入 20 个字符的标签或芯片时显示错误消息。 我想限制客户为芯片或标签输入 20 个字符。

任何建议.......

【问题讨论】:

    标签: angular angular-material


    【解决方案1】:

    Working Demo

    您可以在输入中使用maxLength 属性

       <input placeholder="New fruit..."
                   [matChipInputFor]="chipList"
                   [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
                   [matChipInputAddOnBlur]="addOnBlur"
                   (matChipInputTokenEnd)="add($event)"
                    maxlength=20
                   (input)="onChangeValue($event.target.value)" 
            >
    

    【讨论】:

    • 感谢更新。你能用响应式表单和 maxlength 验证器尝试同样的事情吗?
    猜你喜欢
    • 2021-10-21
    • 1970-01-01
    • 2020-10-06
    • 2020-11-11
    • 2019-08-01
    • 1970-01-01
    • 2021-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多