Advertisement
selvalives

Untitled

Aug 7th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. loadProducts(){
  2. if ($.fn.DataTable.isDataTable(this.Table.nativeElement) ) {
  3. $(this.Table.nativeElement).dataTable().fnDestroy();
  4. }
  5. this.crudService.getProducts().subscribe(
  6. productData => {
  7. this.products = productData;
  8.  
  9. this.dataTable = $(this.Table.nativeElement);
  10. setTimeout(()=>{
  11. this.dataTable.DataTable();
  12. }, 2000);
  13.  
  14. },(err)=>{
  15. }, ()=>{
  16. }
  17. );
  18. }
  19.  
  20. deleteProduct(pID) {
  21. this.crudService.deleteProduct(pID).subscribe(data => {
  22. this.loadProducts();
  23. })
  24. }
  25.  
  26. }
  27.  
  28. <button type="button" class="btn btn-danger" (click)="deleteProduct(product.p_id)">Delete</button>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement