javascript - 如何在angular2中使用bootstrap-table的日期格式化程序?

标签 javascript angular bootstrap-table

您好,我正在将 bootstrap-table 库与 Angular4 一起使用。但使用日期格式化程序并没有给我带来任何值(value)。

代码html:

<table id="table" data-show-refresh="true" data-show-toggle="true" data-show-columns="true">
                                    <thead>
                                        <tr>
                                            <th data-field="state" data-checkbox="true"></th>
                                            <th data-field="userId" data-sortable="true">Usuario</th>
                                            <th data-field="userName" data-sortable="true">Nombre</th>
                                            <th data-field="lastName" data-sortable="true">Apellido</th>
                                            <th data-field="email" data-sortable="true">Correo</th>
                                            <th data-field="mobilePhone">Teléfono</th>
                                            <th data-field="cargo">Cargo</th>
                                            <th data-field="evento" data-formatter="acciones">Eventos</th>
                                        </tr>
                                    </thead>
                                </table>

代码 typescript :

  tableRow(data){
    $(function () {
        $('#table').bootstrapTable({
            data: data,
            pagination: true,
            pageNumber: 1,
            pageSize: 10,
            search: true,
            minimumCountColumns: 2,
            iconsPrefix : 'icon',
            icons: {
              refresh: 'ion-ios-loop-strong',
              toggle: 'ion-ios-list-outline',
              columns: 'ion-ios-more'
            }
        });
    });
    function acciones(){
      return "<a href='/user:id' />Edit</a>";
    }
  }

最佳答案

函数 acciones 仅在 typescript 函数 tableRow 中定义。

bootstrap-tabledata-formatter 似乎使用全局函数(即在 window 中定义)。

这应该有效:

window.acciones = function () {
  return '<a href="/user:id">Edit</a>';
};
<小时/>

注意:我认为 bootstrap-tableAngular 不兼容。我不建议在这种环境中使用 jQuery 插件。

关于javascript - 如何在angular2中使用bootstrap-table的日期格式化程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45744589/

相关文章:

angular - 如果输入长度小于 3,则禁用按钮

html - Bootstrap 类未按预期工作

html - 更改 Bootstrap 表中的排序图标

javascript - 创建给定字符串的指定副本的字符串

javascript - JavaScript 中的动态类型、扩展 Native 和 hasOwnProperty()

javascript - 在客户端 Laravel 中排序/过滤表的最喜欢的方式?

javascript - Dynamics CRM 表单的客户规模操作

angular - 如何在 RxJs Observable 构造函数中使用异步调用

jquery - Bootstrap 表如何使用数据格式化程序中的输入框更改值

javascript - 如何从 Bootstrap 表中获取td点击事件?