import { Component, OnInit } from '@angular/core'; import { ApiService } from 'src/app/api.service'; @Component({ selector: 'app-form', templateUrl: './form.page.html', styleUrls: ['./form.page.scss'], }) export class FormPage implements OnInit { constructor( public _apiService: ApiService ) { } countryName; countryContinent; countryArea; countryPopulation; countryDrivingSide; countryFlag; selectedFile(event){ this.countryFlag = event.target.files[0]; } addCountry(){ var data = new FormData(); data.append("countryName", this.countryName); data.append("countryContinent", this.countryContinent); data.append("countryArea", this.countryArea); data.append("countryArea", this.countryPopulation); data.append("countryDrivingSide", this.countryDrivingSide); data.append("countryFlag", this.countryFlag); console.log(data); this._apiService.addCountry(data).subscribe((response) => { console.log(response); }); // window.location.reload(); } ngOnInit() { } }