Необходимо сделать функцию сохранения и обновления, чтобы редактировать некоторую информацию в форме.Получение ошибок о том, что объект не существует.Я сделал это на другой странице обновления работает нормально, просто по причине не работает на этой странице.
Tried making new objects dynamically and statically.
//
To get the current Place:
async getCurrentPlace
var getId = this.route.snapshot.paramMap.get('id');
const places = await this.placeService.load();
places.forEach(element => {
if(element.id == getId)
this.currentPlace = element
} //this set the correct place up for the object
set new place up:
//getting the new information from the form from the user
preparePlaceData(): Place {
let place = new Place;
place.id = this.currentPlace.id;
place.title = this.form.value.name;
place.category = this.form.value.category;
place.description = this.form.value.description;
place.address = this.form.value.address;
place.website = this.form.value.website;
place.phone = this.form.value.phone;
place.email = this.form.value.email;
place.image = this.mainUpload;
calls this to update the new mongo db
To update the mongodb:
try {
this.isSaving = true;
const place = this.preparePlaceData();
await this.currentPlace .save(place);
place.destroy();
this.form.reset();
this.isSaving = false;