【问题标题】:How to add validation for ng2-smart-table in angular 7?如何在 Angular 7 中为 ng2-smart-table 添加验证?
【发布时间】:2020-01-10 22:17:40
【问题描述】:

我正在使用 ng2-smart-table 来添加员工详细信息。我有姓名、手机、电子邮件等字段。我想为表中的每个字段添加验证。我在 google 中搜索过验证但找不到。谁能帮我解决这个问题。

下面是创建ng2-smart-table的代码

<div class="card-body">
    <ng2-smart-table [settings]="settings" [source]="employeeList" 
    style="font-size: 14px;"></ng2-smart-table>
</div>

add: { addButton: 'Add Employee', createButton: 'Save ' },
                columns: {
                    Employee: {
                        title: 'Employee Name',
                        filter: false
                    },
                    UID: {
                        title: 'Employee ID',
                        filter: false
                    },
                    Mobile: {
                        title: 'Mobile',
                        filter: false
                    },
                    Email: {
                        title: 'Email Id',
                        filter: false
                    },
                    Address: {
                        title: 'Address',
                        filter: false
                    },
                    State: {
                        title: 'State',
                        filter: false
                    }
                },
                attr: {
                    class: 'table table-bordered'
                }
Should show error messages for invalid fields in the table

【问题讨论】:

    标签: angular validation ng2-smart-table


    【解决方案1】:

    据我所知,他们没有任何记录在案的方法可以做到这一点。 但是你可以试试这个修改,它的可配置性要强得多:

    HERE

    但是,如果您仍想使用 ng2-smart-table,您可能需要使用 HTMLElement 在您的 TS/JS 代码中进行自定义验证或动态类

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-28
      • 2020-07-08
      • 1970-01-01
      相关资源
      最近更新 更多