I'm new to Angular, I have a datatable that includes dynamic data, I'm trying to refresh the table whenever I add any data however for some reason the data is not being put unless I refresh the page myself, I read the documentation however, the only option that I found is renderer but it's not giving me the result I'm looking for, also I've searched all over the internet and all of what I found was a work around that didn't even work in my case, I would appreciate if you can help me refresh the table automatically.
employeeposition.component.ts
ngOnInit(): void {
// this approach works great when refreshing dropdown menu, but not in datatables
this.restService.refreshNeeded$.subscribe((res: any) => {
this.getAllPositions();
this.dtOptions = {
destroy: true,
responsive: true,
pagingType: 'full_numbers',
pageLength: 5
};
})
getAllPositions(){
return this.restService.GetAllPositions().subscribe((res: any) => {
this.positions = res.data.positions;
this.dtTrigger.next();
this.loading = false;
})
}