I have a mat-table with a component app-order-statuses on every row.
the component calls the statuses of an order from my server.
however when I load the table, the endpoint is called on every row.
import { Component, Input, OnInit } from '@angular/core';
import { ApiService } from '../../../Services/api-service/api.service';
@Component({
selector: 'app-order-statuses',
templateUrl: './order-statuses.component.html',
styleUrls: ['./order-statuses.component.scss']
})
export class OrderStatusesComponent implements OnInit {
@Input() order_id: any;
public statuses: [];
public isVisible: boolean = true;
constructor(private ApiService: ApiService) { }
ngOnInit() {
let url = 'orders/' + this.order_id + '/statuses';
this.ApiService.get(url).subscribe((response: any) => {
this.statuses = response.data.order_statuses;
this.isVisible = false;
});
}
}
how can I make it that it calls the endpoint only on an event for example (button click).
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)