1) Import NgForm
import {NgForm} from '@angular/forms';
2) Change your form definition to
<form (ngSubmit)="onSubmit(addMountForm)" #addMountForm="ngForm" >
3) Change your component to
import { Component, OnInit } from '@angular/core';
import {NgForm} from '@angular/forms';
@Component({
selector: 'mount-point',
templateUrl: './mountpoint.component.html',
styleUrls: ['./mountpoint.component.scss']
})
export class MountPointComponent implements OnInit {
constructor(
private modalService: NgbModal
){}
ngOnInit(){
}
open(content) {
this.modalService.open(content).result.then((result) => {
console.log("closed");
}, (reason) => {
console.log("dismissed" );
});
}
onSubmit(addMountForm: NgForm){
console.log("adding form values ");
console.log(addMountForm.value);
}
}
This will work, and you will get an object on the console containing all the values of the form.
source
share