ListStore.ts file
export class ListstoreComponent implements OnInit {
rawlist;
name = '';
id = '';
storeid = "";
store: Store;
constructor(private api: APIService, private router: Router, private route: ActivatedRoute, private cookieService: CookieService) { }
ngOnInit() {
this.fetchStoreList();
}
//fetch store list
async fetchStoreList() {
this.rawlist = await this.api.ListStores();
this.storelist = this.rawlist.items;
}
//delete store
async deleteStore(id) {
if (window.confirm('Are you sure, you want to delete?')){
await this.api.DeleteStore(id).catch(data => {
this.refreshStoreList();
})
}
}
HTML File
<button type="button" class="btn btn-primary btn-gap" (click)="deleteStore(Store.id)">Close Ticket</button>
I'm removing the list and updating database. I am uncertain whether catch() would function as expected. I attempted subscribe but it did not work.