Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49336

FormSubmit doesn't update value without refresh page

$
0
0

Hi dear all,

I’m facing to an issue concerning my form submit. When I submit my form, the values are updated well but not reactive. I have to refresh the page to see the modification. I’m using Ionic v4 / Angular 8 / API.

invoice-service.ts

 getInvoice(id:number): Observable<Invoice>{
    return this.http.get<Invoice>(`${environment.apiUrl}api/invoices/${id}`)
}

getInvoiceItems(invoiceId:number): Observable<InvoiceItem[]> {
    return this.http.get<InvoiceItem[]>(`${environment.apiUrl}api/invoiceitems`)
    .pipe(
        map((invoiceitems : InvoiceItem[]) => invoiceitems.filter(inv => inv.invoice_id == invoiceId))
    );
}

 updateInvoiceItems(id:any, invoiceitems:any):Observable<any>{
        return this.http.patch(`${environment.apiUrl}api/invoiceitems/${id}`, invoiceitems, this.httpOptions)
          .pipe(
            tap(_ => console.log(`updated invoice id=${id}`)))
    }

invoice-details.ts

 ngOnInit() {

    this.id = this.route.snapshot.params['id'];

    this.invoiceService.getInvoice(this.id).subscribe(result => {
      this.item = result;
      //console.log(this.item)
    })
    this.invoiceService.getInvoiceItems(this.id).subscribe(result => {
      this.data = result;
     //console.log(this.data)
    })
  }

For my test, I’m using the property

window.location.reload()

but it’s not what I want to do for a clean code.

Thank you

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49336

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>