Coder Social home page Coder Social logo

Comments (3)

marinantonio avatar marinantonio commented on May 16, 2024

Please take a look at (especially commented part):
https://github.com/marinantonio/angular-mat-table-crud/blob/master/src/app/services/data.service.ts

We're using httpClient's error handling, HttpErrorResponse, so once you call one of the methods httpClient will tick error if it happened. It has nothing to do with dialog. Etc. PUT method:

updateItem(kanbanItem: KanbanItem): void {
  this.httpClient.put(this.API_URL + kanbanItem.id, kanbanItem).subscribe(data => {
      this.dialogData = kanbanItem;
      console.log('Successuful, all fine');
    },
    (err: HttpErrorResponse) => {
      console.log('Error occurred. Details: ' + err.name + ' ' + err.message);
    }
  );

Source

from angular-mat-table-crud.

dmushkov avatar dmushkov commented on May 16, 2024

Hi @marinantonio and thanks for pointing this out. I tried this but now I stuck on dialogData variable.
I use angular/material:5.2.4. Behaviour of that version make that piece of code not work as expected.
It seems dialog is already closed but dataService has not yet finished - so push bellow gets wrong (old) value stored in dialogData

For add we're just pushing a new row inside DataService
 this.exampleDatabase.dataChange.value.push(this.dataService.getDialogData() );

gets dialogData before

addItem(kanbanItem: SubscriptionDto): void {
        this.serviceProxy.create(kanbanItem).subscribe((result) => {
           ===>>>> this.dialogData = result; <<<<<=====
            this.toasterService.showToaster('Successfully added', 3000);
        }, err => {
            this.toasterService.showToaster('Error occurred. Details: ' + err.name + ' ' + err.message, 8000);
        });
    }

from angular-mat-table-crud.

marinantonio avatar marinantonio commented on May 16, 2024

I've updated to latest material and I'm still unable to reproduce your issues. What I see from your snippet you're using serviceProxy ? HttpClient uses HTTP Methods (POST, PUT, DELETE), so I'm not sure about create method? Also you might want to check backend response once operation passes. HttpClient usually expects some response and can break if there's none.

from angular-mat-table-crud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.