40 lines
728 B
TypeScript
40 lines
728 B
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ApiService } from 'src/app/api.service';
|
|
|
|
|
|
@Component({
|
|
selector: 'app-list',
|
|
templateUrl: './list.page.html',
|
|
styleUrls: ['./list.page.scss'],
|
|
})
|
|
export class ListPage implements OnInit {
|
|
countries;
|
|
|
|
ionViewWillEnter() {
|
|
this.getCountries();
|
|
}
|
|
constructor(
|
|
public _apiService: ApiService
|
|
|
|
) { }
|
|
getCountries(){
|
|
this._apiService.getCountries().subscribe((data) => {
|
|
this.countries = data;
|
|
console.log(data);
|
|
});
|
|
|
|
|
|
}
|
|
delCountry(countryId, i){
|
|
this._apiService.delCountry(countryId).subscribe((response) => {
|
|
console.log(response);
|
|
});
|
|
this.countries.splice(i, 1);
|
|
|
|
|
|
}
|
|
ngOnInit() {
|
|
}
|
|
|
|
}
|