Мне нужна твоя помощь.Я не знаю, как передать данные, которые я отредактировал в модале.
cohorts.component.html ...
<button class="btn btn-success btn-lg" type="button" (click)="addCohorte(content)">+Add Cohort</button>
<br>
И это cohorts.component.ts
updateCohorte(content, cohort: Cohorte): void {
console.log(this.data)
this.modalService.open(content, {ariaLabelledBy: 'modal-basic-title'}).result.then((result) => {
this.cohorteService.updateCohorte(cohort, result).subscribe(
res => this.getCohortes()
);
}, (reason) => {
});
Мой компонент модального содержимого
modal-content-component.ts
import {Component, Input} from "@angular/core";
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap";
@Component({
selector: 'ngbd-modal-content',
template: `
<div class="modal-header">
<h4 class="modal-title">Hi there!</h4>
<button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="activeModal.close('Close click')">Close</button>
</div>
`
})
export class NgbdModalContent {
@Input() firstName;
@Input() lastName;
@Input() minimumBreakTime;
constructor(public activeModal: NgbActiveModal) {}
}
И мой cohort.service.ts
...
updateCohorte(cohort: Cohorte, data: any): Observable<Cohorte> {
let url = this.UPDATE_COHORTE + '/' + cohort.id;
return this.http.put<Cohorte>(url, data)
}
}