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

How to use the date-formatter of bootstrap-table in angular2?

你好,我在 Angular4 中使用 bootstrap-table 库。但是使用 date-formatter 并没有给我带来任何价值。

代码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>

代码打字稿:

  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只在打字稿函数tableRow中定义。

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

这应该有效:

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

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