我为 notefrais 开发了一个表,但是问题是当我添加 notefrais 时,该表不会自动刷新。是否需要刷新页面以显示新的 notefrais ?如何修改代码以自动刷新此表? (我与angular一起工作)
错误:
错误错误:未捕获(承诺):TypeError:无法读取属性 未定义TypeError的“绘制”:无法读取的属性“绘制” 未定义
async ngOnInit() {
let id = localStorage.getItem('userId');
...
...
this.notes = await this._dashbordService.getNotes(id);
...
setTimeout(function () {
this.table = $('#example-table').DataTable({
pageLength: 2,
"bLengthChange": false,
});
}, 1000);
}
async processAdd() {
let nf = new NoteDeFrais();
let frm = this.addfrm.value;
nf.UserId = this.userId;
...
...
this._dashbordService.addNoteFrais(nf);
this.refreshTable(); // for refresh table after add notefrais but don't work !
}
async refreshTable() {
let id = localStorage.getItem('userId');
this.notes = await this._dashbordService.getNotes(id);
this.table.draw(); // the same problem for this.table.reload()
}