Good night, guys.
In Angular 6, I have the following code:
import { Component, OnInit } from '@angular/core'
import { FormGroup, FormBuilder } from '@angular/forms';
@Component({
selector: 'app-form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.scss'],
})
export class FormComponent implements OnInit {
formulario: FormGroup
constructor(private formBuilder: FormBuilder) {}
ngOnInit() {
this.formulario = this.formBuilder.group({
pesquisa: [null],
})
}
teste() {
console.log(this.formulario.value.pesquisa)
}
}
How can I export the "this.formula" so that I can use it in a service?
I am capturing the data entered in an input via ngSubmit and I want to pass it to the url of an API (which is defined in a service).
I'm a beginner and I do not find solutions clear enough for my understanding.
Thank you.