您好,我正在将 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-table
的 data-formatter
似乎使用全局函数(即在 window
中定义)。
这应该有效:
window.acciones = function () {
return '<a href="/user:id">Edit</a>';
};
<小时/>
注意:我认为 bootstrap-table
与 Angular
不兼容。我不建议在这种环境中使用 jQuery
插件。
关于javascript - 如何在angular2中使用bootstrap-table的日期格式化程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45744589/